fix: short-circuit proxy authorization code redemption#133
fix: short-circuit proxy authorization code redemption#133casey-brooks wants to merge 1 commit intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
QA
|
noa-lucent
left a comment
There was a problem hiding this comment.
Clean, focused hotfix. All three changes are correct:
-
Guard in
issueTokensFromCode— Type-safe check oncode.client.oauthClientMode === "proxy"using the Prisma-typed relation. ThrowsDomainErrorwithinvalid_grant— exactly right for an invariant violation in internal code. -
Improved error message — "Proxy provider tokens are no longer available" is clearer than "Token exchange expired" for the
consumeProxyAuthorizationCodefailure case. -
Regression test — Correctly asserts
fetchMockcall count stays at 1 after proxy code redemption (no additional upstream calls), and validates returned tokens match the stored upstream response.
One minor observation: the test covers the happy path (proxy redemption doesn't call upstream) but doesn't directly unit-test the rejection guard in issueTokensFromCode. Since the primary dispatch is via isProxyCode at the route level and the guard is defense-in-depth, this is acceptable — but a targeted unit test for the throw would strengthen coverage if you revisit.
Approving — no issues found.
Root Cause
Fix
Testing
Closes #106