fix(web): point passport proxy at entity-shape backend route#340
Open
ctol3r wants to merge 1 commit into
Open
Conversation
The web proxy at /api/passport/[npi] was calling the backend's
/api/passport/:npi (loadPassportData / public-or-wallet NPI-shape) but
its validator (assertPassportData) expects the entity-shape — top-level
entityId, identity, authority, training, standing, readiness, sources,
sourceCoverage, lastCheckedAt, trustPosture — that the backend's
/api/passport/npi/:npi (buildPassportDataByNpi) returns.
Result against a seeded NPI:
before: 502 {"error":"invalid_upstream_payload","detail":"…"}
after: 200 with all 14 top-level keys present and valid
Adds a guard test pinning the upstream URL so a regression that
re-routes back to the NPI-shape endpoint can't silently reintroduce
the 502.
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
The web proxy at
apps/web/app/api/passport/[npi]/route.tswas fetching the wrong backend endpoint. The backend has two passport routes with divergent contracts:GET /api/passport/:npi{npi, accessMode, public, credentials, sanctions, privileges, decisions, meta}loadPassportData()inroutes/passport.ts(public/wallet/selective modes)GET /api/passport/npi/:npi{entityId, identity, authority, training, standing, readiness, sources, sourceCoverage, lastCheckedAt, trustPosture, ...}buildPassportDataByNpi()viaroutes/passportEntity.tsThe web proxy's validator
assertPassportData(inapps/web/lib/trust/passport-contract.ts) is built for the entity-shape, but the proxy was calling the NPI-shape route. Every seeded NPI returned 502invalid_upstream_payload.Fix
One-line URL change in the proxy:
/api/passport/${npi}→/api/passport/npi/${npi}.Adds a guard test (
passport-proxy-routes.test.ts:new case) that asserts the upstream URL contains/api/passport/npi/so this can't regress.Validation against live runtime
Truth rules
Validation
__tests__/passport-proxy-routes.test.ts)pnpm turbo run build --filter @vitalcv/web— 13/13 tasks, 39sScope
apps/web/app/api/passport/[npi]/route.ts(1-line URL change + comment)apps/web/__tests__/passport-proxy-routes.test.ts(1 guard test added)