Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Root-cause hypothesis: empty proxy codes likely come from upstream token exchange failures before minting/storing a proxy auth code; diagnostics now log issued=false when exchange errors occur. Test & Lint Summary
|
noa-lucent
left a comment
There was a problem hiding this comment.
Review Summary
Good feature direction — the proxy flow diagnostics capture valuable debug data (full request/response payloads, headers, params, exchange details). The void → await fix for audit writes is appreciated, the ProxyCodeIssuedDetails extension with issued/authorizationCode is useful, and the test coverage is thorough with well-extracted helpers.
Major (4)
-
PROXY_FLOW_DIAGNOSTICfires for all token requests — not just proxy flows. Non-proxy auth-code grants emit proxy diagnostics, which is semantically wrong and creates noise. -
DB call before input validation —
getApiResourceWithTenant()now runs beforevalidation.successis checked, adding unnecessary DB + audit load for malformed requests. -
Redundant boundary re-validation in internal code —
typeof response.json !== "object" || Array.isArray(response.json)checks inproxy-token-service.ts:363andproxy-callback-service.ts:344re-validate whatrequestProviderTokensalready guarantees via its return type. Simplify to!response.json. -
Repeated audit-emit boilerplate —
completeProxyRefreshGranthas 7emitAuditEventcalls repeating the same envelope. Extract a closure (likeproxy-callback-service.tsdoes withrecordCallbackError).
Minor (1)
handleProxyCallbackis ~380 lines — adding closures and mutable flags within a monolithic function. Consider splitting at the "transaction resolved" seam.
Nit (1)
ProviderTokenResponsecontract — the distinction betweenjsonParseError=trueandjson=null, jsonParseError=false(valid JSON but wrong shape) is implicit. A comment would help.
Note: Please disregard the comment on proxy-service.ts:282 — it was filed in error and self-contradicts. Apologies for the noise.
Please address the major items.
|
Summary:
Tests:
@noa Please re-review. |
noa-lucent
left a comment
There was a problem hiding this comment.
All four major issues from the prior review are resolved:
- PROXY_FLOW_DIAGNOSTIC scoping — removed from the token route entirely; now emitted only inside
completeProxyAuthorizationCodeGrantandcompleteProxyRefreshGrant. - Validation before DB calls —
validation.successcheck moved before the try block, restoring early-return for invalid requests. - Redundant shape checks — simplified to
!response.json/!result.json, trusting the boundary type contract. - Audit-emit boilerplate —
recordRefreshErrorclosure incompleteProxyRefreshGrant+ newemitProxyFlowDiagnosticutility inaudit-service.tseliminate the repetition.
Additional improvements in this commit: cleaned up the double isProxyCode lookup, removed the unnecessary typeof entries.client_id === "string" checks (now using typed Record<string, string>), and fixed test code verifiers to meet Zod's min(43) constraint.
LGTM — clean and well-structured.
|
Summary:
Migration policy:
Tests:
|
Summary
Testing
#122