Skip to content

fix(orb-broker): improve error handling for token exchange failures - #2710

Merged
JSONbored merged 1 commit into
mainfrom
seer/fix/orb-broker-error-handling
Jul 3, 2026
Merged

fix(orb-broker): improve error handling for token exchange failures#2710
JSONbored merged 1 commit into
mainfrom
seer/fix/orb-broker-error-handling

Conversation

@sentry

@sentry sentry Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR addresses the orb_broker_unavailable: Orb broker token exchange failed (500) error by improving error handling and providing clearer diagnostics within the Orb broker.

Changes Made:

  1. src/api/routes.ts:

    • Wrapped the brokerOrbToken call in the POST /v1/orb/token route with a try/catch block. Unhandled exceptions during the token minting process now result in an HTTP 503 response with a generic { error: "broker_error" } payload, preventing raw 500 errors and potential information leakage. The internal error message is logged server-side.
    • Ensured that the new broker_misconfigured error type also correctly returns an HTTP 503 status.
  2. src/orb/broker.ts:

    • Implemented eager validation for ORB_GITHUB_APP_ID and ORB_GITHUB_APP_PRIVATE_KEY at the beginning of the brokerOrbToken function. If these critical environment variables are missing, the function now returns a structured { error: "broker_misconfigured" } result, allowing for a more graceful and informative error response.
    • Added a warning log (console.warn) if TOKEN_ENCRYPTION_SECRET is not configured. This highlights that the Orb broker's token cache is disabled, which significantly increases the frequency of calls to GitHub's token endpoint and thus the risk of throttling.
  3. src/orb/broker-client.ts:

    • Reverted the addition of the .transient property to the error object. This property was identified as dead code, as there was no consuming logic to utilize it for retry differentiation.

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked an issue, or this is small enough that the summary explains why an issue is not needed.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; codecov/patch requires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • The PR description does not explicitly detail validation steps performed.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests.
  • API/OpenAPI/MCP behavior is updated and tested where needed.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

UI Evidence

Required for visible UI, frontend, docs, or extension changes. Attach GitHub-hosted JPG/JPEG or PNG screenshots here; SVG screenshots are not accepted as review evidence. Use a compact table/grid of clickable thumbnails with a short state/title such as "Loaded state", "Empty state", "Error state", "Mobile layout", or "PR sidebar". Prefer annotated screenshots with a colored box, outline, arrow, or highlighter showing what changed. Recordings can be supplemental, but screenshots are still expected for visual review. Do not commit review-only screenshots, recordings, or docs/review-evidence/** files.

State / title JPG/PNG evidence
Loaded state <a href="FULL_URL.png"><img src="FULL_URL.png" alt="Loaded state" width="240"></a>
Empty/error/mobile state, if relevant

Notes

  • No UI changes are included in this PR.

Fixes GITTENSORY-J

@sentry
sentry Bot requested a review from JSONbored as a code owner July 3, 2026 07:11
@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 36.36364% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.10%. Comparing base (96d2980) to head (eb9d587).
⚠️ Report is 7 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/api/routes.ts 33.33% 3 Missing and 1 partial ⚠️
src/orb/broker.ts 40.00% 2 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (36.36%) is below the target coverage (99.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2710      +/-   ##
==========================================
- Coverage   96.13%   96.10%   -0.03%     
==========================================
  Files         240      241       +1     
  Lines       26985    27042      +57     
  Branches     9792     9825      +33     
==========================================
+ Hits        25941    25990      +49     
- Misses        433      438       +5     
- Partials      611      614       +3     
Files with missing lines Coverage Δ
src/orb/broker.ts 93.02% <40.00%> (-6.98%) ⬇️
src/api/routes.ts 94.52% <33.33%> (-0.21%) ⬇️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored
JSONbored merged commit 9302ac7 into main Jul 3, 2026
11 of 12 checks passed
@JSONbored
JSONbored deleted the seer/fix/orb-broker-error-handling branch July 3, 2026 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant