fix(orb): return 503 instead of a bare 500 from the relay register/pull routes - #5017
Merged
Merged
Conversation
…ll routes /v1/orb/relay/register and /v1/orb/relay/pull both call DB-touching functions (validateOrbRelayEnrollment, registerValidatedOrbRelay, pullRelayPending) with no error handling of their own -- an unhandled D1/Postgres error escaped as a bare framework 500, the same class of gap #orb-broker-500 already closed for /v1/orb/token's own DB-touching call. drainOrbRelay's client-side in-flight guard and matched poll/request timeout (src/server.ts) were already correct; the gap was entirely server-side. `.catch(...)` on just the two DB-touching calls per handler, rather than wrapping the whole handler in try/catch, keeps the diff minimal and leaves existing logic/branches untouched. Closes #4995
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5017 +/- ##
=======================================
Coverage 94.35% 94.36%
=======================================
Files 457 457
Lines 39216 39228 +12
Branches 14300 14306 +6
=======================================
+ Hits 37004 37016 +12
Misses 1558 1558
Partials 654 654
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Contributor
|
Important 🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪 🔍 Gittensory is reviewing…AI analysis is in progress. This comment will update when the review is complete. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed · 🟪 Reviewing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
drainOrbRelayreturned HTTP 500 repeatedly (872 Sentry events, escalating).drainInFlightguard insrc/server.ts, and the 30s poll interval is explicitly matched todrainOrbRelay's own 30sAbortSignal.timeout, per that code's own comment). The real gap was entirely server-side:/v1/orb/relay/registerand/v1/orb/relay/pullboth call DB-touching functions (validateOrbRelayEnrollment,registerValidatedOrbRelay,pullRelayPending) with no error handling of their own. An unhandled D1/Postgres error inside either one escaped as a bare framework 500 — exactly the class of gap#orb-broker-500already closed for/v1/orb/token's own DB-touching call, just never applied to these two sibling routes..catch(...)on just the two DB-touching calls per handler (not a big try/catch wrapping the whole handler), so pre-existing logic/branches keep their original indentation and coverage — genuine DB failures now return a clean503 { error: "broker_error" }.Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Closes #4995).Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocallynpm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:check(confirms these internal broker routes aren't part of the public OpenAPI surface — no drift)npm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
test:coverage(full unsharded): not run end-to-end — ran scopedvitest --coveragefortest/integration/orb-relay.test.tsand confirmed via lcov that every line/branch in this diff (both the register and pull handlers' new.catch()paths, including theerror instanceof ErrorvsString(error)branch) is covered — including a second regression test per handler after the first pass showed one call site's error path was untested. The one remaining zero-hit branch in the surrounding function is confirmed pre-existing (same branch was already 0% covered before this diff, verified viagit stash) and structurally unreachable at this call site givenRegisterResult's real producers — not introduced by this change.test:workers/build:mcp/test:mcp-pack/ui:lint/ui:typecheck/ui:build: not run — this change touches onlysrc/api/routes.tsand its integration test; no Worker-pool, MCP, or UI-component surface changed.Safety
UI Evidencesection. (N/A.)Notes
Part of a batch of 13 bug fixes filed from a Sentry-issue triage this session (#4994–#5006). This is #2 by impact.