Skip to content

feat: alert when a connector sync unit is dead-lettered - #5533

Merged
themarolt merged 3 commits into
mainfrom
feat/issue-1238-sync-unit-dead-letter-alert
Dec 6, 2026
Merged

themarolt merged 3 commits into
mainfrom
feat/issue-1238-sync-unit-dead-letter-alert

Conversation

@themarolt

Copy link
Copy Markdown
Contributor

Summary

A connector sync unit that fails too often in a row is dead-lettered and never runs again until someone acts, and today nothing tells anyone. A new hourly cron job posts dead-lettered units to the CDP integrations alerts Slack channel. With one Octolens poll unit per workspace, a rejected workspace key now shows up there instead of silently stopping that workspace's mentions.

Changes

  • listDeadLetteredSyncUnits (DAL): dead-lettered sync units of live integrations, with their segment, failure count and last error.
  • sync-unit-dead-letter-check cron job (hourly at :45, production only): alerts once per dead-letter episode, keyed in Redis by the unit and the time of the run that dead-lettered it, so a unit revived and dead-lettered again alerts again. A unit still dead after 7 days is listed again as a reminder. A failed Slack send is retried on the next run.
  • The alert lists up to 20 units with platform, sync, channel, project, failure count and last error, and says how to bring a unit back (Octolens discovery revives its own units once the workspace key works again).

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Performance improvement
  • Chore / dependency update
  • Documentation

Related issue

Refs linuxfoundation/lfx-cdp-insights-ops#1238

A sync unit that dead-letters (for example after repeated auth failures)
stopped silently. An hourly cron job lists dead-lettered units of live
integrations and sends one Slack alert per dead-letter episode, with a weekly
reminder while a unit stays dead.

Refs linuxfoundation/lfx-cdp-insights-ops#1238

Signed-off-by: Uroš Marolt <uros@marolt.me>
…unit-dead-letter-alert

Signed-off-by: Uroš Marolt <uros@marolt.me>

# Conflicts:
#	services/libs/data-access-layer/src/connectors/syncUnits.test.ts
@themarolt
themarolt requested review from a team and lfx-one as code owners December 6, 2026 19:16
Copilot AI balanced review requested due to automatic review settings December 6, 2026 19:16
@cursor

cursor Bot commented Dec 6, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Read-only DB queries plus Redis-backed Slack deduplication; no changes to sync unit lifecycle or dead-letter transitions.

Overview
Adds visibility when connector sync units enter dead-letter state (stopped after repeated failures with no automatic retries).

A new DAL query listDeadLetteredSyncUnits returns dead-lettered units on non-deleted integrations, including segment, failure count, and last error fields.

A production-only cron job sync-unit-dead-letter-check (hourly at :45) posts to CDP_INTEGRATIONS_ALERTS. It alerts only for new episodes, tracked in Redis by unit id and the lastRunAt of the run that dead-lettered the unit, so re-dead-lettering after revive alerts again. Redis keys expire after 7 days to re-list long-standing issues; failed Slack sends are not recorded so the next run retries. Messages list up to 20 units and reuse octolensMappingHealth formatting helpers.

Unit tests cover the check logic (dedupe, reminders, failed sends) and the DAL listing (excludes deleted integrations).

Reviewed by Cursor Bugbot for commit f25bb5a. Bugbot is set up for automated code reviews on this repo. Configure here.

@lfx-one

lfx-one commented Dec 6, 2026 •

Copy link
Copy Markdown

@themarolt I'm starting review 1 of this pull request now (started 2026-12-06 19:16 UTC using review agent v0.1.37). This usually takes a few minutes. I'll update this comment with the summary when I'm done. If there's no summary here after about 45 minutes, the review stopped: push a new commit, or post a comment that begins with a mention of me followed by re-review, to start another. For help with the review agent, see https://github.com/linuxfoundation/lfx-review-agent/issues.


Hi @themarolt, thanks for the PR.

Summary

This PR adds an hourly cron job that posts dead-lettered connector sync units to the CDP integrations alerts Slack channel. It also adds the DAL query behind it. The code is well structured and tested, and I found one minor edge case.

Decision

✅ Approved with minor comments

🟡 1 minor

Details

Overall impression: The change is small and well scoped. The new job reuses the Octolens health-check helpers (capLines, formatName) and the same Redis episode-key pattern. The pure runSyncUnitDeadLetterCheck function takes injected dependencies, so it is easy to test, and the tests cover the quiet, once-per-episode, revived-unit and failed-send paths. The DAL query only lists units of non-deleted integrations and has an integration test. The one finding is that units cut from the alert by the 20-line or character cap are still marked as alerted.

🟡 Minor: 1 issue: Units not shown in the alert are still marked as alerted

Other reviewers and CI checks: Cursor Bugbot had only posted a "generating summary" placeholder, so there was nothing to reconcile. The required DCO check passed on f25bb5a.

Documentation reminder: changed sync-unit-dead-letter-check, sync-unit-dead-letter:alerted:. Please check product pages and external docs; the author and maintainers own those updates.

Rule files: read AGENTS.md; skipped none

Questions, problems, or feedback: https://github.com/linuxfoundation/lfx-review-agent/issues

@lfx-one lfx-one left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dead-letter alert job is a clean, well-tested addition that follows the existing Octolens health-check pattern. I found one minor edge case, listed below, which doesn't block approval.

Documentation

This pull request changes behavior that may also be described outside this repository, such as product pages or an external docs site. I can't read those, so please check them; the author and maintainers own those updates. Changed here:

  • sync-unit-dead-letter-check (new hourly cron job that alerts on dead-lettered sync units)
  • sync-unit-dead-letter:alerted: (new Redis key prefix for the per-episode alert state)

@greptile-apps

greptile-apps Bot commented Dec 6, 2026 •

Copy link
Copy Markdown

Confidence Score: 4/5RetriggerView in Greptile

[Medium impact] The alerts cover dead-lettered units across live integrations, while their effects stay in the operations notification workflow.

Not ready to merge: units omitted from Slack are still marked as alerted, and the comment rule remains unmet.

FindingsFix All in Claude Code

  1. P1 Omitted units stay hidden ▶
  2. P2 Comments repeat the code ▶
Fix with agent prompt
### Issue 1
services/apps/cron_service/src/jobs/syncUnitDeadLetter.ts:99-104
`buildAlert` drops units beyond the line or character limit, but this loop marks every fresh unit as alerted for seven days. With 21 short entries, Slack never names the last unit. If the units stay dead, weekly reminders repeat the same first entries and hide the rest again. Send separate batches and remember only units included in successful messages.

### Issue 2
services/apps/cron_service/src/jobs/syncUnitDeadLetter.ts:undefined-8
This comment repeats `REMINDER_DAYS`. The comment above `listDeadLetteredSyncUnits` also repeats the function and query. `AGENTS.md` explicitly forbids comments that only describe what the code does, so remove these before merging. Keep the separate comments explaining why `lastRunAt` identifies an episode; those explain a non-obvious invariant.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds hourly, production-only Slack alerts for dead-lettered connector sync units.

  • Operators get Slack alerts when live integrations have dead-lettered sync units.

Reviews (2) · Last reviewed commit: "Merge branch 'main' into feat/issue-1238..." · Reviewed by Greptile

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The alert loop marks omitted units as alerted for seven days, suppressing notifications for units excluded by the message limits.

1 open issue
What changed in this PR

Adds Slack monitoring for dead-lettered connector sync units, making stopped ingestion visible to operators.

Changes:

  • Queries dead-lettered units belonging to live integrations.
  • Adds a production-only hourly alert with Redis deduplication and weekly reminders.
  • Tests query filtering, alert suppression, repeat episodes, and failed sends.
File Description
services/​libs/​data-access-layer/​src/​connectors/​syncUnits.ts Adds the dead-letter query and result type.
services/​libs/​data-access-layer/​src/​connectors/​syncUnits.test.ts Tests filtering and timestamp conversion.
services/​apps/​cron_service/​src/​jobs/​syncUnitDeadLetterCheck.job.ts Connects the hourly job to PostgreSQL, Redis, and Slack.
services/​apps/​cron_service/​src/​jobs/​syncUnitDeadLetter.ts Formats alerts and tracks notified episodes.
services/​apps/​cron_service/​src/​jobs/​syncUnitDeadLetter.test.ts Tests alert delivery and deduplication behavior.

Review effort: Balanced

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f25bb5a. Configure here.

@themarolt
themarolt merged commit 8db8537 into main Dec 6, 2026
13 checks passed
@themarolt
themarolt deleted the feat/issue-1238-sync-unit-dead-letter-alert branch December 6, 2026 19:26
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.

3 participants