Skip to content

fix(notifications): include job name, exit code, and logs in job run alerts - #868

Merged
Hydralerne merged 1 commit into
oblien:feat/bugfix-integration-2026-09-15from
chbndrhnns:fix/867-job-notification-details
Sep 15, 2026
Merged

Hydralerne merged 1 commit into
oblien:feat/bugfix-integration-2026-09-15from
chbndrhnns:fix/867-job-notification-details

Conversation

@chbndrhnns

Copy link
Copy Markdown
Contributor

Fixes #867

Context

When a scheduled or manual command job fails (e.g. custom:BlS_iYp2_kUnHTbj), the notification category description (apps/api/src/lib/notification-categories.ts:160) promises:

"A scheduled or manual job run errored out. Includes the job + exit code."

However, in practice the alert message only contained:

A scheduled or manual job run errored out. Includes the job + exit code.
Resource: job (custom:BlS_iYp2_kUnHTbj)

The human-readable job name/label was never printed, the exit code was omitted, and error output logs were completely absent.

Changes

  1. Pass outcome metadata in job-command.ts:
    • Update runLoop to pass durationMs, exitCode, error, and output to emitJobRun.
    • Update emitJobRun to include jobName: row.label, exitCode, errorMessage, and a bounded logExcerpt (last 20 lines, max 2000 chars) in the notification payload.
  2. Render job metadata in notification-workers.ts (renderMessage):
    • Render Job: ${payload.jobName ?? payload.label}.
    • Render Exit Code: ${payload.exitCode}.
    • Render Logs:\n${payload.logExcerpt}.
  3. Tests:
    • Added unit tests in apps/api/test/lib/notification-headline.test.ts verifying that job failure and success alerts render Job:, Exit Code:, Error:, Duration:, and Logs:.
    • Added unit test in apps/api/test/modules/jobs/job-command.test.ts verifying that failing command runs emit notifications containing jobName, exitCode, errorMessage, and logExcerpt.

Verification

  • Ran vitest test suites (apps/api/test/modules/jobs/job-command.test.ts and apps/api/test/lib/notification-headline.test.ts), all 19 tests passing.
  • Ran typecheck/build (bun run --cwd apps/api build), succeeded without errors.
  • Formatted with Prettier.

@Hydralerne

Hydralerne commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

Incorporated this PR into feat/bugfix-integration-2026-09-15 via 505b91ee, preserving the original commits and adapting the fix to the current architecture.

Job alerts include the real exit status, name, duration, sanitized log tail, and failure reason.

GitHub now records this contributor PR as merged into the integration branch. The integrated changes are tested and awaiting merge to main.

Validation:

  • 71 jobs/API/SDK-parity/notification tests passed
  • Two notification regressions failed against the unchanged source

@Hydralerne Hydralerne closed this Sep 15, 2026
@Hydralerne Hydralerne reopened this Sep 15, 2026
@Hydralerne
Hydralerne changed the base branch from main to feat/bugfix-integration-2026-09-15 September 15, 2026 18:25
@Hydralerne
Hydralerne merged commit 505b91e into oblien:feat/bugfix-integration-2026-09-15 Sep 15, 2026
3 checks passed
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.

[Bug]: Job run failure notifications omit job name, exit code, and logs

2 participants