Merged
Conversation
mcmire
reviewed
Mar 6, 2026
packages/geolocation-controller/src/geolocation-api-service/geolocation-api-service.test.ts
Outdated
Show resolved
Hide resolved
packages/geolocation-controller/src/geolocation-api-service/geolocation-api-service.ts
Show resolved
Hide resolved
Contributor
|
@MarioAslau Could you also update the changelog file ? |
Contributor
|
@MarioAslau FYI, this repo has its own pull request template, it doesn't use the same template as extension/mobile. Updating changelogs also follows a different process. |
Contributor
Author
Found it! Thanks for pointing that out! I configured a mono repo folder with cursor rules at the root, to allow the agent to learn from both codebases for more complex cross repo implementations. I'm modifying it ! |
mcmire
approved these changes
Mar 6, 2026
Contributor
mcmire
left a comment
There was a problem hiding this comment.
Tests could be more comprehensive, but I guess they can be adjusted as the need arises.
github-merge-queue bot
pushed a commit
that referenced
this pull request
Mar 6, 2026
## Explanation <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> Includes Geolocation Controller Patch: #8137 ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk release bookkeeping only: version and changelog updates with no functional code changes in this diff. > > **Overview** > **Release bump:** Updates the root monorepo version to `854.0.0`. > > **Package release:** Bumps `@metamask/geolocation-controller` to `0.1.1` and updates its `CHANGELOG.md` to document the fix for accepting ISO 3166-2 subdivision codes from the geolocation API. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 91ab404. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
7 tasks
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.
Explanation
The
/geolocationAPI endpoint returns ISO 3166-2 subdivision codes (e.g.US-NY,CA-ON,GB), not ISO 3166-1 alpha-2 country-only codes (e.g.US,CA,GB).The
GeolocationApiService.#performFetch()validation regex was/^[A-Z]{2}$/u, which only accepts exactly 2 uppercase letters. Since the API returns values likeUS-NY, the regex rejects every valid response and the controller always storesUNKNOWN.This causes all downstream consumers to receive
UNKNOWNas the geolocation:EligibilityServicedefaults to eligible forUNKNOWN.Fix: Updated the validation regex to
/^[A-Z]{2}(-[A-Z0-9]{1,3})?$/u, which accepts both 2-letter country codes (US,GB) and country+subdivision codes (US-NY,CA-ON). This matches the actual API response format and is consistent with the previous mobile implementation (useDetectGeolocation), which stored the raw API response with no validation.Updated all JSDoc references from "ISO 3166-1 alpha-2" to "ISO 3166-2" to accurately reflect the API contract.
References
Checklist
Note
Medium Risk
Changes geolocation response validation to allow ISO 3166-2 subdivision codes, which can affect region-based eligibility/geo-blocking decisions across consumers. Logic change is small (regex + tests/docs) but touches compliance-sensitive behavior.
Overview
Fixes geolocation parsing to match the API contract.
GeolocationApiService.#performFetch()now accepts ISO 3166-2 codes (country plus optional subdivision likeUS-NY,CA-ON) instead of rejecting everything except 2-letter country codes.Updates JSDoc/auto-generated method action docs and the package changelog to describe the new location-code format, and expands the service test suite to cover valid/invalid subdivision variants.
Written by Cursor Bugbot for commit 2a922f4. This will update automatically on new commits. Configure here.