fix(openapi): declare 503 on the BYOK key setters and drop the unreachable GET 404 - #9819
Conversation
…hable GET 404
The four BYOK key-write routes answer 503 `encryption_unavailable` when
TOKEN_ENCRYPTION_SECRET is unconfigured, but their spec entries never declared it —
so a generated client had no schema for the one failure a maintainer actually
hits. The two public key GETs declared a 404 they can never return: the handler
answers 200 `{ configured: false }` for an unregistered repo, never a 404.
In the per-`kind` flatMap that generates all four key routes (so ai-key and
linear-key can't drift), add 503 to the public and internal setters and remove the
404 from the public getter. No handler behaviour changes. openapi.json regenerated.
Closes JSONbored#9709
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
Warning ⏸️ LoopOver review result - manual review recommendedReview updated: 2026-07-29 11:34:52 UTC
Review summary Nits — 4 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. Visual preview
Click any thumbnail to open the full-size screenshot. Before = production · After = this PR's preview deploy. Scroll preview
A short scroll-through clip (desktop) — click either thumbnail to open the full animation. Evidence for scroll-linked behavior a single screenshot can't show. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9819 +/- ##
=======================================
Coverage 79.03% 79.03%
=======================================
Files 280 281 +1
Lines 58366 58379 +13
Branches 6697 6699 +2
=======================================
+ Hits 46128 46141 +13
Misses 11955 11955
Partials 283 283
Flags with carried forward coverage won't be shown. Click here to find out more.
|


What & why
The four BYOK key-write routes (
POSTpublic + internalai-key/linear-key) catchmissing_encryption_secretand answer 503encryption_unavailablewhenTOKEN_ENCRYPTION_SECRETis unconfigured — but their spec entries never declared503, so a generated client had no schema for the one failure a maintainer actually hits.Conversely, the two public key GETs declared a 404 they can never return: the handler answers
200 { configured: false }for an unregistered repo, never a 404.The fix
In the per-
kindflatMapinsrc/openapi/orb-and-control-route-specs.ts— the single place all four key routes are generated, soai-keyandlinear-keycan't drift:503(encryption_unavailable — TOKEN_ENCRYPTION_SECRET is not configured) to the public and internal setters, matching the 503 description style used forPOST /v1/internal/provider-credentials/{provider};404from the public getter.No handler behaviour changes.
apps/loopover-ui/public/openapi.jsonregenerated.Tests (
test/unit/routes-ai-byok.test.ts)POST /v1/repos/:owner/:repo/ai-keywith no secret answers503 { error: "encryption_unavailable" }andbuildOpenApiSpec()declares503for that operation (fails onmain).POST /v1/internal/repos/:owner/:repo/linear-key(fails onmain).GET /v1/repos/:owner/:repo/ai-keyfor a repo with no key answers200 { configured: false }, and the spec's GET no longer declares404— proving the removed 404 was unreachable (fails onmain).Validation
npm run typecheckgreen;npm run ui:openapi:checkclean; the byok, openapi, route-spec-ratchet, and security-parity suites all green.git diff --check <base> HEADclean; diff is the spec source + its test + the regeneratedopenapi.json; no handler or lockfile change.Closes #9709