Skip to content

fix(web): guard parseBrowserLanguages against invalid locale tags - #190651

Merged
auto-submit[bot] merged 6 commits into
flutter:masterfrom
sankalpsthakur:fix/190510-locale-bootstrap-guard
Sep 18, 2026
Merged

auto-submit[bot] merged 6 commits into
flutter:masterfrom
sankalpsthakur:fix/190510-locale-bootstrap-guard

Conversation

@sankalpsthakur

@sankalpsthakur sankalpsthakur commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #190510

Engine bootstrap calls DomLocale(language) for every navigator.languages entry with no validation. A bad tag (e.g. en-US@posix from Chromium when LANG is unset) throws during field init and leaves a blank page.

Guard each tag with try/catch and skip invalid ones. If all fail, fall back to _defaultLocale (en-US).

Tests: en-US@posix, mixed invalid+valid, empty list via debugOverrideBrowserLanguages.

AI tools helped with drafting.

@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@google-cla

google-cla Bot commented Aug 6, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. platform-web Web applications specifically team-web Owned by Web platform team labels Aug 6, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the locale parsing logic in EnginePlatformDispatcher to handle invalid locale tags gracefully. It wraps the DomLocale instantiation and parsing in a try-catch block to ignore tags rejected by Intl.Locale (such as en-US@posix on Linux). Additionally, it replaces the assertion that locales must not be empty with a fallback that returns a list containing _defaultLocale when no valid locales are found. There are no review comments, and I have no further feedback to provide.

@mdebbar
mdebbar self-requested a review August 6, 2026 18:25
@sankalpsthakur
sankalpsthakur force-pushed the fix/190510-locale-bootstrap-guard branch from e7853e6 to 5d29668 Compare August 7, 2026 17:38
@sankalpsthakur

sankalpsthakur commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor Author

@navaronbracke added tests for en-US@posix via debugOverrideBrowserLanguages and all-invalid falling back to en_US. fixed commit email so CLA matches. 5d29668.

@sankalpsthakur

sankalpsthakur commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor Author

@navaronbracke added en-US@posix / mixed-invalid / empty cases via debugOverrideBrowserLanguages. Should match what you asked for.

navaronbracke
navaronbracke previously approved these changes Aug 8, 2026
@sankalpsthakur
sankalpsthakur force-pushed the fix/190510-locale-bootstrap-guard branch from 5d29668 to d4c10b8 Compare August 11, 2026 08:48
mdebbar
mdebbar previously approved these changes Aug 11, 2026

@mdebbar mdebbar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing this fix!

@mdebbar mdebbar added the CICD Run CI/CD label Aug 11, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Aug 11, 2026
@mdebbar mdebbar added the CICD Run CI/CD label Aug 11, 2026
@sankalpsthakur
sankalpsthakur dismissed stale reviews from mdebbar and navaronbracke via 95f447b August 12, 2026 16:18
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Aug 12, 2026
@sankalpsthakur
sankalpsthakur force-pushed the fix/190510-locale-bootstrap-guard branch from 95f447b to 2cf28b7 Compare August 12, 2026 16:35
@mdebbar
mdebbar self-requested a review September 9, 2026 18:23
@mdebbar mdebbar added the CICD Run CI/CD label Sep 18, 2026
@flutter-dashboard

Copy link
Copy Markdown

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #190651 at sha b36529d

@flutter-dashboard flutter-dashboard Bot added the will affect goldens Changes to golden files label Sep 18, 2026
@navaronbracke navaronbracke added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 18, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Sep 18, 2026
Merged via the queue into flutter:master with commit fa78ae3 Sep 18, 2026
34 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD engine flutter/engine related. See also e: labels. platform-web Web applications specifically team-web Owned by Web platform team will affect goldens Changes to golden files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[web] App fails to bootstrap (permanent blank page) when navigator.languages contains a tag Intl.Locale rejects

3 participants