Skip to content

fix(core): gracefully discard queue messages when process not found#584

Draft
d-klotz wants to merge 1 commit into
nextfrom
fix/queue-worker-process-not-found-graceful
Draft

fix(core): gracefully discard queue messages when process not found#584
d-klotz wants to merge 1 commit into
nextfrom
fix/queue-worker-process-not-found-graceful

Conversation

@d-klotz

@d-klotz d-klotz commented May 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • loadIntegrationForProcess now returns null instead of throwing when a process is not found
  • QueueWorker processId hydration branch checks for null and discards the message gracefully
  • Follows the same pattern already used by loadIntegrationForWebhook for missing integrations

Root Cause

When a sync process completes while FETCH_PERSON_PAGE messages are still in the SQS queue, loadIntegrationForProcess throws Error(Process not found). This error has no statusCode, so it gets retried 4 times then DLQed.

Production Evidence (Quo, 2026-05-11)

  • 7 DLQ events in 24h (up from 3/day), all FETCH_PERSON_PAGE with integrationId: null
  • 18 total DLQ events from this pattern

Test plan

  • New test: discard message when process not found
  • New test: still throw for other hydration errors (DB failures)
  • All 23 existing tests pass

When a sync process is deleted mid-flight (e.g., completed or cancelled
while pagination messages are still in the queue), loadIntegrationForProcess
threw an unclassified error. Since the error has no statusCode, the queue
worker retried it 4 times before sending it to DLQ — wasting Lambda
invocations on a permanently unrecoverable condition.

Now loadIntegrationForProcess returns null (matching loadIntegrationForWebhook
pattern), and the QueueWorker discards the message with a warn log.

Production evidence: 7 DLQ events/day for FETCH_PERSON_PAGE with
integrationId: null, all processIds belonging to already-completed syncs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
42.2% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

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