Skip to content

fix(router): forward project credentials to sentry-bound workers#1259

Merged
zbigniewsobiecki merged 1 commit intodevfrom
fix/sentry-worker-env-credentials
May 6, 2026
Merged

fix(router): forward project credentials to sentry-bound workers#1259
zbigniewsobiecki merged 1 commit intodevfrom
fix/sentry-worker-env-credentials

Conversation

@zbigniewsobiecki
Copy link
Copy Markdown
Member

Summary

extractProjectIdFromJob had no sentry branch — sentry jobs hit the return null fall-through, so buildWorkerEnvWithProjectId skipped credential loading entirely (the if (projectId) gate at worker-env.ts:133). The worker spawned without CASCADE_CREDENTIAL_KEYS, the in-worker resolver auto-selector at src/config/provider.ts:164-179 fell back to DbCredentialResolver, hit an encrypted Trello row, and crashed with Credential is encrypted but CREDENTIAL_MASTER_KEY is not set — workers intentionally don't carry the master key (see worker-env.ts:132).

Why this surfaced now

This was the first sentry-bound agent run in prod (cascade project, 2026-05-06 12:48 UTC). Router pipeline succeeded end-to-end (webhook parsed → SentryIssueAlertTrigger matched → BullMQ queued → worker spawned). Only the worker boot failed, with [WorkerManager] Spawning worker: hasCredentials: false then Worker exited: statusCode: 1, oomKilled: false, durationMs: 2622.

Fix

One-line branch in extractProjectIdFromJob returning jobData.projectId for sentry jobs (SentryJob.projectId is already populated by SentryRouterAdapter.buildJob).

Test plan

  • Added regression test in tests/unit/router/worker-env.test.ts — fails on main, passes after fix
  • npm test — all 8794 unit tests pass
  • npm run typecheck clean
  • npm run lint clean (no new warnings)
  • Post-merge: fire another Sentry test alert from the cascade project, confirm cascade runs list --project cascade --agent alerting shows a non-crashed run

Follow-ups (not in this PR)

  • When worker boot fails before the dashboard "run started" call, no run record exists and the failure is only visible via Sentry. Add a router-side incident log keyed by jobId so this class of failure has a non-Sentry trail.

🤖 Generated with Claude Code

`extractProjectIdFromJob` had no `sentry` branch, so sentry jobs hit the
`return null` fall-through and `buildWorkerEnvWithProjectId` skipped
credential loading entirely (the `if (projectId)` gate). Worker spawned
without `CASCADE_CREDENTIAL_KEYS`, the in-worker resolver auto-selector
fell back to `DbCredentialResolver`, hit an encrypted row, and crashed
with "CREDENTIAL_MASTER_KEY is not set" — workers intentionally don't
have the master key.

This was the first sentry-bound agent run in prod (cascade project,
2026-05-06 12:48 UTC). The router pipeline succeeded end-to-end; only
the worker boot failed.

Add the `sentry` branch (sentry jobs carry `projectId` directly per
`SentryJob.projectId`) and pin the regression in the worker-env unit
test.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zbigniewsobiecki zbigniewsobiecki merged commit c222290 into dev May 6, 2026
8 checks passed
@zbigniewsobiecki zbigniewsobiecki deleted the fix/sentry-worker-env-credentials branch May 6, 2026 13:05
@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/router/worker-env.ts 66.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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