Skip to content

fix(notifications): include destination and policy in backup run alerts - #866

Merged
Hydralerne merged 1 commit into
oblien:feat/bugfix-integration-2026-09-15from
chbndrhnns:fix/865-backup-notification-references
Sep 15, 2026
Merged

Hydralerne merged 1 commit into
oblien:feat/bugfix-integration-2026-09-15from
chbndrhnns:fix/865-backup-notification-references

Conversation

@chbndrhnns

Copy link
Copy Markdown
Contributor

Summary

Includes destination and policy references in backup failure and success notifications, and renders project and service names when available, ensuring operators receive complete context when a backup job finishes or errors out.

Motivation

The notification category description for backup.failed in apps/api/src/lib/notification-categories.ts:138 states:

"A scheduled or manual backup run errored out. Includes the destination + policy that failed."

Because this category description is printed at the top of the alert body, delivered notification emails explicitly announce that destination and policy are included, but then omit them:

  1. backup.orchestrator.ts only passed destinationName and errorMessage on failure (omitting policyName, policyId, projectName, serviceName).
  2. renderMessage in apps/api/src/lib/notification-workers.ts did not check or render destinationName or policyName.
  3. In backup.orchestrator.ts, failure notification emission was gated on destination lookup succeeding via policy?.destinationId. If the policy or destination lookup failed, notification.emit was skipped entirely instead of using run.organizationId, silently dropping the failure alert.

Related issue

Closes #865

Changes

  • apps/api:
    • backup.orchestrator.ts:
      • In failure notifications, resolve destination using policy?.destinationId ?? run.destinationId and provide destinationName, policyName, policyId, projectName, and serviceName.
      • Fall back to run.organizationId so notification dispatch is never dropped if policy or destination resolution throws.
      • In success notifications, include policyName and policyId in the payload.
    • notification-workers.ts:
      • In renderMessage, format Project:, Service:, Policy:, and Destination: lines when present in the payload.
  • apps/api/test:
    • notification-headline.test.ts: Add unit tests verifying renderMessage formats policy, destination, project, and service names for both failure and success alerts.

Verification

Ran all notification and backup test suites:

$ cd apps/api && bun run test test/lib/notification*.test.ts
Test Files  6 passed (6)
     Tests  38 passed (38)

$ cd apps/api && bun run test test/modules/backups/backup-run-durability.test.ts
Test Files  1 passed (1)
     Tests  17 passed (17)

$ cd apps/api && bun run lint
$ tsc --noEmit

Checklist

  • One change per PR — one bug, or one agreed feature, with nothing unrelated bundled in
  • The diff is scoped — no reformatting or lint fixes on lines I wasn't otherwise changing
  • A test fails without this change and passes with it
  • bun run test, bun run --cwd <workspace> lint, and bun format all pass locally
  • I understand every line of this diff and can explain it in review

@Hydralerne

Hydralerne commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

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

Backup alerts include policy and destination references even when lookups fail.

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

Validation:

  • 29 affected notification and backup tests passed, including a missing policy plus failed destination lookup

@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 98bbf60 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.

[Improvement]: Include destination and policy references in backup job notifications

2 participants