Skip to content

fix(api): refused device proofs and source map upload races stay off error tracking - #3237

Merged
Makisuo merged 1 commit into
mainfrom
fix/errors-api-2026-12-03
Dec 3, 2026
Merged

Makisuo merged 1 commit into
mainfrom
fix/errors-api-2026-12-03

Conversation

@Makisuo

@Makisuo Makisuo commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Error triage sweep 2026-12-03, api area.

Fixed

  • 05cc7b06 DpopProofRejected "The proof jti was already used.": a refused DPoP proof (and a rejected device token) is always answered as a 401, but the inner span exported Error. Both are now in the api's anticipated 4xx list; worker-bridge.test.ts covers them.
  • 10aa60e0 DatabaseError duplicate key on source_map_files_org_release_path_idx: two uploads of the same map raced between the read and the insert. The retry already replaced the winner's row (all 147 uploads in the sample succeeded), but the unique violation marked the database span Error. The insert now uses ON CONFLICT DO NOTHING and the upload runs its write once more when no row comes back. The race test now lands the winner between the read and the insert and asserts no statement fails.

Already fixed on main

Dismissed

  • ecd4ba4d WarehouseConfigError "Resource 'person_properties' not found" (332) and 18509229 WarehouseSchemaDriftError on service_platforms_hourly: both came from the 11-24 rollout window, when code that read the new datasource and columns was live before the warehouse deploy landed. No events since 11-24 20:28.
  • 59c8643e WarehouseUpstreamError 520 on audit_log inserts: transient upstream 520s. The queue retried them and every batch ended Ok.
  • afd71516 QueryEngineTimeoutError: one 30s timeout on 11-25, nothing since.
  • 40963d6f, 0dd59e2f chat history 503: the chat session call in the ai worker failed during a deploy (11-24..11-26). Nothing since, and the ai side owns the cause.
  • 8aec7da0 POST /v2/share/og-meta 400: three requests from curl, someone testing by hand.
  • 80600c85 Integration connect failed: one Search Console connect where the user did not grant the Search Console scope. The rule worked as intended.

Left in todo

  • a16d89e6 usersRecentFloor hit its 20s client timeout once (p50 138ms, p99 6s over 136 runs). A change needs bench:queries against a large org first.
  • b1f5848e iOS "No such alert incident.": the app opened an incident push, switched org, then fetched the incident with the previous org's token and got a 404. The fix belongs in the iOS app (token refresh after select), not the API.

🤖 Generated with Claude Code


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

Summary by CodeRabbit

  • Bug Fixes
    • Concurrent uploads of the same source map are handled more reliably, avoiding a failed upload when another upload saves the map at the same time.
    • Rejected DPoP proofs and device tokens are now recognized as anticipated API errors, improving how these failures are reported in telemetry.

… off error tracking

A replayed or otherwise refused DPoP proof, and a rejected device token, are
always answered as a 401, so the api now lists them with its other errors
answered as 4xx and their spans export Ok.

Two uploads of the same source map racing between the read and the insert
made Postgres raise a unique violation, which marked the database span Error
even though the retry then replaced the winner's row. The insert now skips
the conflict and the upload runs its write again.
@maple-review-bot

maple-review-bot Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Maple review

🟢 Confidence 10/10 · safe to merge. Contained change: error tags verified against the classes, and the upload race is pinned by a test that fails if the conflict stops being absorbed.
no findings · tests covered · risk medium

Adds the api's device-auth refusals to its anticipated 4xx list, and replaces the source map upload's retry-on-unique-violation with ON CONFLICT DO NOTHING plus one re-run. Safe to merge.

  • DpopProofRejected and DeviceTokenRejected now export as Ok on api spans
  • SourceMapService.upload inserts with onConflictDoNothing() and re-runs the write when no row returns
  • SourceMapRowConflict and the SQLSTATE 23505 retry are removed

55d384b · What was checked, coverage and telemetry details are on the Maple / review check. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The anticipated API error list now includes rejected DPoP proofs and device tokens, with worker-bridge test coverage. Source-map uploads use conflict-ignoring inserts and retry once when an insert returns no row. The concurrency test verifies that the competing insert causes no failed database execution.

Changes: API error classification

Layer / File(s) Summary
Anticipated error identifiers and coverage
apps/api/src/telemetry-options.ts, apps/api/src/worker-bridge.test.ts
The anticipated error identifiers now include rejected DPoP proofs and device tokens. Worker-bridge tests check that these errors receive 4xx responses without Error spans.

Source-map upload concurrency

Layer / File(s) Summary
Concurrent source-map insert handling
packages/backend/src/services/sourcemaps/SourceMapService.ts, packages/backend/src/services/sourcemaps/SourceMapService.test.ts
Uploads use the general storage-error executor and conflict-ignoring inserts. If the first write returns no row, upload retries once and combines the prior rows from both attempts. The race test asserts zero failed database executions.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

  • MapleTechLabs/maple#1774: Adds the DPoP device-credential flow that produces the refused DPoP-proof and rejected device-token errors covered here.

Suggested reviewers: jeremyfunk

Merge Risk: Minimal · up to 55d38

Refused device proofs and tokens should stop appearing as errors in tracking, and concurrent source-map uploads should no longer produce failed database spans. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names both changes in the PR: refused device proofs (DPoP) and rejected device tokens are kept off error tracking, and source map upload races are handled without error spans. The changeset …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names both changes in the PR: refused device proofs (DPoP) and rejected device tokens are kept off error tracking, and source map upload races are handled without error spans. The changeset adds DpopProofRejected and DeviceTokenRejected to the anticipated 4xx identifiers, and removes the unique-violation classifier from SourceMapService in favor of ON CONFLICT DO NOTHING with a retry. The title covers the main changes, though it does not mention the ON CONFLICT rework.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 86e5aa1b-76d4-4c31-aba3-baa92da8fa8a
Commits

Reviewing files that changed from the base of the PR and between e6a01d7 and 55d384b.

Files selected for processing: 4

  • apps/api/src/telemetry-options.ts
  • apps/api/src/worker-bridge.test.ts
  • packages/backend/src/services/sourcemaps/SourceMapService.test.ts
  • packages/backend/src/services/sourcemaps/SourceMapService.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review.

@Makisuo
Makisuo merged commit c785450 into main Dec 3, 2026
45 checks passed
@Makisuo
Makisuo deleted the fix/errors-api-2026-12-03 branch December 3, 2026 11:47
@maple-review-bot

Copy link
Copy Markdown

Maple: after this shipped

✅ Shipped clean. Nothing this change touches got worse in the hour after it deployed.

Deployed at 2026-12-03 12:24 UTC as c785450. Compared the 60 minutes before and after.

  • 1 operations compared, 0 regressed

Details are in Maple. A public repository's comment names no service, operation or error.

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