Skip to content

fix(flowlord): Alert results will show in dashboard - #270

Merged
jbsmith7741 merged 3 commits into
mainfrom
flowlord-alerts
Sep 18, 2026
Merged

jbsmith7741 merged 3 commits into
mainfrom
flowlord-alerts

Conversation

@jbsmith7741

Copy link
Copy Markdown
Collaborator
  • Alerted tasks will show in the alerts dashboard
  • more concise message with task+job + alert message rather than full JSON

  - more concise message with task+job + alert message rather than full JSON
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix Flowlord alert persistence and Slack message formatting

🐞 Bug fix ✨ Enhancement 🕐 10-20 Minutes

Grey Divider

AI Description

• Persist AlertResult tasks so they appear in the dashboard and scheduled summaries.
• Replace immediate Slack JSON payloads with concise task, job, message, and report details.
Diagram

sequenceDiagram
    participant Task as Task Result
    participant TM as Task Master
    participant DB as Alert Store
    participant UI as Dashboard
    participant Slack as Slack
    participant Tick as Batch Ticker
    Task->>TM: Deliver alert task
    TM->>DB: Persist alert record
    UI->>DB: Query dated alerts
    alt AlertResult
        TM->>Slack: Send concise alert
    end
    Tick->>TM: Trigger summary
    TM->>DB: Query pending alerts
    DB-->>TM: Return alert records
    TM->>Slack: Send batch summary
Loading
High-Level Assessment

Persisting alerts centrally in the notification handler is the best fit because every task accepted by that channel becomes dashboard-visible while AlertResult retains its immediate Slack behavior. Persisting earlier in Process was considered but would duplicate alert eligibility rules and risk recording retries or suppressed failures.

Files changed (2) +138 / -7

Bug fix (1) +27 / -7
taskmaster.goPersist all queued alerts and format immediate Slack messages +27/-7

Persist all queued alerts and format immediate Slack messages

• Stores every task received by the notification handler in alert_records, including AlertResult tasks previously excluded from dashboard and batch-summary data. Immediate AlertResult notifications now contain the report link, task type, optional job, and alert message instead of the full task JSON; the job falls back to task metadata when necessary.

apps/flowlord/taskmaster.go

Other (1) +111 / -0
go.work.sumSynchronize workspace dependency checksums +111/-0

Synchronize workspace dependency checksums

• Adds checksums for newly resolved transitive module versions, primarily Google Cloud packages and related Go dependencies. This records workspace dependency verification metadata without changing application behavior.

go.work.sum

@qodo-code-review

qodo-code-review Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Midnight links omit persisted alerts 🐞 Bug ≡ Correctness
Description
formatImmediateAlert builds the report date with local time.Now(), while AddAlert leaves
created_at to SQLite's UTC CURRENT_TIMESTAMP and the dashboard filters that stored date. When
the process's local calendar day differs from UTC, the immediate link requests one day and the new
record appears under another.
Code

apps/flowlord/taskmaster.go[R616-617]

+	message.WriteString(fmt.Sprintf("see report at %v:%d/web/alert?date=%s\n",
+		tm.HostName, tm.port, time.Now().Format("2006-01-02")))
Evidence
The new path first inserts the AlertResult without a created_at value and then formats the link
from the process-local clock. The schema supplies CURRENT_TIMESTAMP, while dashboard lookup
applies DATE(created_at) to the persisted value, allowing the linked date and stored date to
diverge around timezone boundaries.

apps/flowlord/taskmaster.go[596-617]
apps/flowlord/sqlite/alerts.go[54-64]
apps/flowlord/sqlite/alerts.go[69-81]
apps/flowlord/sqlite/schema.sql[78-85]
apps/flowlord/handler.go[411-417]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The persisted alert date and immediate dashboard-link date come from different clocks and time zones, so they can identify different days around midnight.

## Fix Focus Areas
- apps/flowlord/taskmaster.go[596-617]
- apps/flowlord/sqlite/alerts.go[54-64]
- apps/flowlord/sqlite/schema.sql[78-85]
- apps/flowlord/handler.go[411-417]

## Recommended Fix
Capture one UTC creation timestamp for the alert, persist it explicitly as `created_at`, update the date index from that same value, and pass it to the formatter for the URL date. Add a test using a non-UTC local timezone across a UTC date boundary.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Alerts link to disabled dashboard ✓ Resolved 🐞 Bug ≡ Correctness
Description
formatImmediateAlert always interpolates tm.port into a report URL even when zero disables the
HTTP router. Because status_port defaults to zero, an otherwise valid immediate alert tells Slack
recipients to open localhost:0/..., where no dashboard is listening.
Code

apps/flowlord/taskmaster.go[R616-617]

+	message.WriteString(fmt.Sprintf("see report at %v:%d/web/alert?date=%s\n",
+		tm.HostName, tm.port, time.Now().Format("2006-01-02")))
Evidence
The default options leave Port at zero and copy it into tm.port. StartHandler explicitly
returns without listening for that value, but the newly added formatter still places the value in
every immediate AlertResult message.

apps/flowlord/main.go[35-64]
apps/flowlord/taskmaster.go[179-193]
apps/flowlord/handler.go[147-154]
apps/flowlord/taskmaster.go[614-629]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Immediate alert messages always include a dashboard URL, although a zero status port is a supported configuration that disables the dashboard server.

## Fix Focus Areas
- apps/flowlord/taskmaster.go[614-629]
- apps/flowlord/handler.go[147-154]
- apps/flowlord/main.go[53-64]

## Recommended Fix
Only append the report URL when `tm.port` is nonzero. When the dashboard is disabled, send the concise task, job, and alert message without advertising an unreachable URL, and add coverage for both configurations.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
Review mode: ⚖️ Balanced: The PR changes runtime alert persistence and Slack formatting on a task-processing path, creating behavioral risk, while the large go.work.sum update is largely mechanical.

Grey Divider

Tip of the day
💡 Did you know, you can type 'qodo, fix this' on a finding and the fix lands right on your PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread apps/flowlord/taskmaster.go Outdated
Comment thread apps/flowlord/taskmaster.go Outdated
  - don't show link to dashboard if port is disabled
@jbsmith7741
jbsmith7741 merged commit bbd9495 into main Sep 18, 2026
3 of 5 checks passed
@jbsmith7741
jbsmith7741 deleted the flowlord-alerts branch September 18, 2026 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant