Skip to content

Let the API manage domains in SES; report pg-boss errors as errors - #340

Merged
pumfleet merged 2 commits into
mainfrom
fix/sentry-triage
Nov 5, 2026
Merged

pumfleet merged 2 commits into
mainfrom
fix/sentry-triage

Conversation

@pumfleet

@pumfleet pumfleet commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes for the two Sentry issues that weren't noise. The rest have been resolved or ignored in Sentry with a note on each.

API-2: POST /v1/domains fails in production (AccessDenied)

/v1/domains runs the same SesIdentityProvider as the dashboard, but cossPolicies().api only allowed ses:SendEmail. So in production, adding a domain through the API that needs a new SES tenant or identity is denied by IAM, and the customer gets a 502 provider_error. Since 2026-11-01, 31 attempts from one organization (org_01m69gamf9fr5v3r3rnnvesjfp, one API key) have all failed. Verifying and deleting domains through the API need the same permissions too.

The API now shares the dashboard's domain statements (manageDomains): tenants limited to the coss-* prefix, identities created and changed only with the coss_managed tag. It gets nothing for dedicated IPs or inbound simulation. A test keeps the API's and the dashboard's SES statements equal and lists the actions the provider calls.

After merge: the live coss/coss-api policy changes only when ses:bootstrap runs (from the worker image of the merge commit, see README "Deploying to AWS"). Until then, API-2 keeps happening, which is why the commit says Refs API-2 rather than Fixes.

WORKER-8: [jobs] pg-boss error: [object Object]

pg-boss emits some errors as plain copies ({ ...error, message, stack }). Sentry's console capture only recognizes Error instances, so these arrived without their message. logPgBossError turns them back into errors (keeping message, stack and code). It is used by both jobs.ts and migrate.ts.

Checks

  • bun run --cwd packages/db test and bun run --cwd apps/worker test: pass (on a fresh test database)
  • turbo run typecheck --affected: pass
  • Biome on the changed files: pass

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

pg-boss emits some errors as plain copies ({ ...error, message, stack }), which Sentry's console
capture can't recognize, so during the database restart on 2026-11-03 they arrived as
"[jobs] pg-boss error: [object Object]". They are errors again before they are logged.

Fixes WORKER-8
POST /v1/domains runs the same SesIdentityProvider as the dashboard, but the API's IAM policy only
allowed sending, so in production every domain that needed a new SES tenant or identity failed with
AccessDenied and customers got a 502. The API now shares the dashboard's domain statements (tenants,
associations, identities, still limited by the prefix and the coss_managed tag). A test keeps the two
equal and lists what the provider calls.

Takes effect once ses:bootstrap has updated the live policy.

Refs API-2
@pumfleet
pumfleet added this pull request to the merge queue Nov 5, 2026
Merged via the queue into main with commit c907265 Nov 5, 2026
14 checks passed
@pumfleet
pumfleet deleted the fix/sentry-triage branch November 5, 2026 20:37
@linear-code

linear-code Bot commented Nov 5, 2026

Copy link
Copy Markdown

ENG-8174

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