Repository navigation
INTER-2613: fix: reject prototype keys in region validation - #294
Merged
Merged
Conversation
`region in Region` also matched inherited keys such as `toString` or `constructor`, so `?region=toString` routed requests to `https://toString.api.fpjs.io`. Validate against the enum values instead, and build the ingress host prefix from the validated region. The invalid-region ingress tests asserted inside the mocked `https.request`, where the transport layer swallowed failures. They now assert after the handler returns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RrYGTcXedRKZWrV3LUKzDw
JuroUhlar
requested review from
Orkuncakilkaya,
TheUnderScorer,
ilfa and
mcnulty-fp
as code owners
October 26, 2026 13:15
Contributor
🚀 Following releases will be created using changesets from this PR:@fingerprint/azure-frontdoor-proxy@2.2.2Patch Changes
|
Contributor
Coverage report
Test suite run success165 tests passing in 57 suites. Report generated by 🧪jest coverage report action from dfe9ae7 Show full coverage report
|
TheUnderScorer
approved these changes
Oct 26, 2026
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused validation fix and effective regression assertions address the reported routing issue without any identified blocking issues.
No open issues 🎉
What changed in this PR
This PR hardens region validation in the Azure Front Door proxy so object prototype keys fall back to the default US region instead of producing invalid upstream hostnames.
Changes:
- Validate regions against supported enum values and build hostnames from the validated result.
- Add prototype-key regression coverage and move ingress URL assertions outside mocked requests so failures are observable.
- Add a patch changeset.
| File | Description |
|---|---|
proxy/utils/region.ts |
Restricts validation to supported region values. |
proxy/utils/region.test.ts |
Tests valid regions and fallback for invalid values and prototype keys. |
proxy/handlers/ingress.ts |
Uses the validated region for the hostname prefix. |
proxy/handlers/ingress.test.ts |
Adds prototype-key cases and fixes URL assertion placement. |
proxy/handlers/ingress_v4.test.ts |
Applies the same regression checks to V4 ingress. |
.changeset/region-prototype-keys.md |
Documents the routing fix for a patch release. |
Review effort: Balanced
This branch was previously deployed
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.
Problem
getValidRegionusedregion in Region.inalso matches prototype keys, so?region=toString(orconstructor,hasOwnProperty) passed validation.getIngressAPIHostthen built the host from the raw value:https://toString.api.fpjs.io.Found during the INTER-2613 spike.
Changes
proxy/utils/region.ts: validate with anisRegiontype guard (Object.values(Region).includes(...)). This also removes the type assertion and its eslint-disable comment.proxy/handlers/ingress.ts: build the host prefix from the validated region.proxy/utils/region.test.ts.ingress.test.tsandingress_v4.test.tsnow cover prototype keys.transport.tscaught the error. The assertion now runs after the handler returns, with the corrected expected URL.Checks
pnpm lint,pnpm test:dtsandpnpm testpass (22 files, 165 tests). Before the fix, 10 prototype-key tests failed.Follow-up
The "Suffix with a dot" ingress tests use the same never-failing assertion pattern. They are not changed here.
Generated by Claude Code