Skip to content

[flutter_tools] Fix version cache poisoning from git environment variables#186595

Merged
auto-submit[bot] merged 7 commits into
flutter:masterfrom
kevmoo:fix_version_check
May 26, 2026
Merged

[flutter_tools] Fix version cache poisoning from git environment variables#186595
auto-submit[bot] merged 7 commits into
flutter:masterfrom
kevmoo:fix_version_check

Conversation

@kevmoo

@kevmoo kevmoo commented May 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #180421
Fixes #178160

Addresses issues where running flutter inside git hooks
would cause the tool to incorrectly cache version info from the user's
project instead of the SDK.

  1. Added environment filtering to strip inherited GIT_* variables from
    SDK-related git commands, ensuring accurate version detection.
  2. Refined FlutterVersion factory to only fall back to git if the
    cached version looks suspicious (e.g. unknown channel), avoiding
    startup latency for healthy installations.
  3. Updated ensureVersionFile to proactively sync the cache when called.
  4. Improved flutter doctor messages with hints on how to reset a
    corrupted version cache.
  5. Updated Git.logSync to support passing custom environments.

…ables

Fixes flutter#180421
Fixes flutter#178160

Addresses issues where running flutter inside git hooks
would cause the tool to incorrectly cache version info from the user's
project instead of the SDK.

1. Added environment filtering to strip inherited GIT_* variables from
   SDK-related git commands, ensuring accurate version detection.
2. Refined FlutterVersion factory to only fall back to git if the
   cached version looks suspicious (e.g. unknown channel), avoiding
   startup latency for healthy installations.
3. Updated ensureVersionFile to proactively sync the cache when called.
4. Improved flutter doctor messages with hints on how to reset a
   corrupted version cache.
5. Updated Git.logSync to support passing custom environments.
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 15, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label May 15, 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 introduces environment variable filtering for Git commands to prevent local project settings from interfering with Flutter SDK version detection. It adds logic to re-verify the Flutter version if cached data is suspicious and updates error messages to suggest cache deletion. Feedback includes improving cross-platform compatibility of error messages, adding GIT_COMMON_DIR to the filtered variables, and ensuring case-insensitive environment key filtering for Windows.

Comment thread packages/flutter_tools/lib/src/doctor.dart Outdated
Comment thread packages/flutter_tools/lib/src/doctor.dart Outdated
Comment thread packages/flutter_tools/lib/src/version.dart Outdated
Comment thread packages/flutter_tools/lib/src/version.dart Outdated
@github-actions github-actions Bot removed the CICD Run CI/CD label May 15, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 15, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label May 16, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 20, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label May 20, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 25, 2026
@bkonyi bkonyi self-requested a review May 25, 2026 17:11
@bkonyi bkonyi added the team-tool Owned by Flutter Tool team label May 25, 2026
@kevmoo kevmoo added the autosubmit Merge PR when tree becomes green via auto submit App label May 25, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue May 26, 2026
Merged via the queue into flutter:master with commit 3ac51d8 May 26, 2026
171 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 26, 2026
@kevmoo kevmoo deleted the fix_version_check branch May 26, 2026 17:20
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request May 26, 2026
Roll Flutter from e03b91f1fe34 to f3a4b9897834 (63 revisions)

flutter/flutter@e03b91f...f3a4b98

2026-05-26 47866232+chunhtai@users.noreply.github.com Update batch release doc to reflect latest workflow (flutter/flutter#186979)
2026-05-26 engine-flutter-autoroll@skia.org Roll Skia from 0442274cc696 to 27a819894f7c (5 revisions) (flutter/flutter#187094)
2026-05-26 bkonyi@google.com [Tool Robustness] Gracefully handle asynchronous subprocess crashes and connection timeouts (flutter/flutter#186964)
2026-05-26 bkonyi@google.com [pubspec] Bump Dart SDK constraint to ^3.13.0 (flutter/flutter#186957)
2026-05-26 engine-flutter-autoroll@skia.org Roll Dart SDK from 7eb54169841d to 00e625453c43 (1 revision) (flutter/flutter#187086)
2026-05-26 bdero@google.com [Impeller] Retire Y-coord-scale plumbing by flipping GLES at the vertex stage (flutter/flutter#186556)
2026-05-26 engine-flutter-autoroll@skia.org Roll Skia from f4f294bdf98d to 0442274cc696 (2 revisions) (flutter/flutter#187079)
2026-05-26 kevmoo@users.noreply.github.com [flutter_tools] Fix version cache poisoning from git environment variables (flutter/flutter#186595)
2026-05-26 bkonyi@google.com [Tool] Handle DTD connection failures gracefully in widget-preview (flutter/flutter#186952)
2026-05-25 engine-flutter-autoroll@skia.org Roll Skia from 9d1adb5f2427 to f4f294bdf98d (1 revision) (flutter/flutter#187056)
2026-05-25 engine-flutter-autoroll@skia.org Roll Skia from 4dd78179e6ec to 9d1adb5f2427 (1 revision) (flutter/flutter#187048)
2026-05-25 engine-flutter-autoroll@skia.org Roll Skia from 1f26101197bf to 4dd78179e6ec (4 revisions) (flutter/flutter#187044)
2026-05-24 engine-flutter-autoroll@skia.org Roll Skia from bbe9ccc2bdbf to 1f26101197bf (1 revision) (flutter/flutter#187016)
2026-05-24 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from nsgcNDlZOuweOvy3Q... to Itd2Jq_ZIABH2rW7B... (flutter/flutter#187032)
2026-05-23 engine-flutter-autoroll@skia.org Roll Dart SDK from 7e0f28eb5315 to 7eb54169841d (1 revision) (flutter/flutter#187005)
2026-05-23 engine-flutter-autoroll@skia.org Roll Dart SDK from 90e55fa88456 to 7e0f28eb5315 (1 revision) (flutter/flutter#186990)
2026-05-23 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 6T6BY9PTftoG3vP_1... to nsgcNDlZOuweOvy3Q... (flutter/flutter#186984)
2026-05-23 chris@bracken.jp iOS] Migrate VSyncClient to a pure Obj-C implementation (#186166) (flutter/flutter#186935)
2026-05-23 30870216+gaaclarke@users.noreply.github.com Disables embedder_tests.cm for fuchsia (flutter/flutter#186969)
2026-05-23 engine-flutter-autoroll@skia.org Roll Dart SDK from b8414c46f6c7 to 90e55fa88456 (2 revisions) (flutter/flutter#186977)
2026-05-22 engine-flutter-autoroll@skia.org Roll Skia from 6fdb013d1953 to bbe9ccc2bdbf (1 revision) (flutter/flutter#186980)
2026-05-22 mdebbar@google.com [web] Fix cutoff text in WebParagraph (flutter/flutter#186819)
2026-05-22 1961493+harryterkelsen@users.noreply.github.com fix(web): Removes the iterative downscaling hack (flutter/flutter#186914)
2026-05-22 30870216+gaaclarke@users.noreply.github.com opts the linux embedder into sdf rendering (flutter/flutter#186909)
2026-05-22 engine-flutter-autoroll@skia.org Roll Skia from dae8778ca40d to 6fdb013d1953 (5 revisions) (flutter/flutter#186970)
2026-05-22 dacoharkes@google.com Fix hooks inputs outputs rebuilt (flutter/flutter#186701)
2026-05-22 30870216+gaaclarke@users.noreply.github.com adds linux impeller integration test for external textures (flutter/flutter#186759)
2026-05-22 kevmoo@users.noreply.github.com fix(flutter_tools): defensively catch DWDS unregistered service extension errors (flutter/flutter#186896)
2026-05-22 bdero@google.com [Impeller] Add golden harness support to the renderer test layer (flutter/flutter#186735)
2026-05-22 mdebbar@google.com [web] Remove image codecs from canvaskit_chromium (flutter/flutter#178133)
2026-05-22 30870216+gaaclarke@users.noreply.github.com opts all macos into wide gamut (flutter/flutter#186277)
2026-05-22 engine-flutter-autoroll@skia.org Roll Skia from 356185490a75 to dae8778ca40d (9 revisions) (flutter/flutter#186949)
2026-05-22 1598289+lukemmtt@users.noreply.github.com Filter out SwiftPM schemes when fetching schemes (flutter/flutter#186006)
2026-05-22 engine-flutter-autoroll@skia.org Roll Packages from 3754d04 to 69cf959 (1 revision) (flutter/flutter#186950)
2026-05-22 engine-flutter-autoroll@skia.org Roll Dart SDK from eca46bec956d to b8414c46f6c7 (2 revisions) (flutter/flutter#186944)
2026-05-22 30870216+gaaclarke@users.noreply.github.com Saves a DeviceHolderVK with the CommandPoolVK (flutter/flutter#186749)
2026-05-22 engine-flutter-autoroll@skia.org Roll Dart SDK from e0d509fd676e to eca46bec956d (1 revision) (flutter/flutter#186922)
2026-05-22 bkonyi@google.com [ Tool ] Stop generating widget preview scaffold under $TMP (flutter/flutter#186476)
2026-05-21 737941+loic-sharma@users.noreply.github.com Fix typo in StretchingOverscrollIndicator docs (flutter/flutter#186897)
2026-05-21 engine-flutter-autoroll@skia.org Roll Dart SDK from 28c7cb5a8e8d to e0d509fd676e (1 revision) (flutter/flutter#186903)
2026-05-21 jason-simmons@users.noreply.github.com Fix some issues in the integration between EmbedderExternalViewEmbedder and Impeller (flutter/flutter#184905)
2026-05-21 jason-simmons@users.noreply.github.com Fix a potential buffer overflow in the animated PNG decoder when parsing malformed fdAT chunks (flutter/flutter#186700)
2026-05-21 engine-flutter-autoroll@skia.org Roll Skia from 2ff20950975d to 356185490a75 (5 revisions) (flutter/flutter#186892)
2026-05-21 flar@google.com Add primitive shadows to rendering benchmark (flutter/flutter#186779)
2026-05-21 15619084+vashworth@users.noreply.github.com Move prefetchSwiftPackages to be per platform (flutter/flutter#186468)
2026-05-21 okorohelijah@google.com Upgrade iOS version (flutter/flutter#186889)
...
@bkonyi

bkonyi commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

hey @bkonyi this seemed to introduce a 4s regression in compilation time. Can you please give this a look and make sure this is the correct tradeoff or not some sort of mistake? Thanks.

https://flutter-flutter-perf.luci.app/e/?begin=1779547355&enable_chart_tooltip=true&end=1780330155&keys=X1cd7b32cc7afcba55c20230412e2f59f&plotSummary=true&selected=commit%3D2808027%26name%3D%252Carch%253Darm%252Cbranch%253Dmaster%252Cconfig%253Ddefault%252Cdevice_type%253Dnone%252Cdevice_version%253Dnone%252Chost_type%253Dwin%252Csub_result%253Drelease_initial_compile_millis%252Ctest%253Dhello_world_win_desktop__compile%252C%26tableCol%3D15%26tableRow%3D627&use_titles=true&xbaroffset=2808027

Is there any way to see the logs, or how those benchmarks are run? There's nothing obvious here in this change that should impact compilation time, unless we're hitting Git when we weren't before, but that's hard to determine without more context.

@gaaclarke

Copy link
Copy Markdown
Member

Is there any way to see the logs, or how those benchmarks are run?

Typically what I'd do at this point is run the test locally and do static code analysis. I've never tracked down the performance run.

@kevmoo

kevmoo commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

@gaaclarke – I'm investigating! I think I have a fix!

@bkonyi

bkonyi commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

@kevmoo beat you to it 😉

#187400

@kevmoo

kevmoo commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

@bkonyi – so close! #187401

I'll let you run w/ it. But take a look at mine too and compare notes?

bkonyi added a commit to bkonyi/flutter that referenced this pull request Jun 1, 2026
Fixes a performance regression introduced in flutter#186595 where healthy
SDK installations on developer or PR branches (detected as '[user-branch]')
were treated as suspicious, forcing a slow Git fallback on every command.

1. Refined `isSuspicious` to check for non-standard `repositoryUrl`
   instead of `[user-branch]` channel.
2. Improved `repositoryUrl` detection to fallback to `origin` remote
   if no upstream is configured, ensuring healthy dev branches can
   resolve a standard remote.
3. Fixed `isGitRepo` check to support Git worktrees where `.git` is a file.
4. Added `ssh://git@github.com/flutter/flutter.git` to standard remotes list to support SSH environments.
5. Updated and fixed associated unit tests in `version_test.dart`, including a new test case for SSH standard remote.
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
…r#11789)

Roll Flutter from e03b91f1fe34 to f3a4b9897834 (63 revisions)

flutter/flutter@e03b91f...f3a4b98

2026-05-26 47866232+chunhtai@users.noreply.github.com Update batch release doc to reflect latest workflow (flutter/flutter#186979)
2026-05-26 engine-flutter-autoroll@skia.org Roll Skia from 0442274cc696 to 27a819894f7c (5 revisions) (flutter/flutter#187094)
2026-05-26 bkonyi@google.com [Tool Robustness] Gracefully handle asynchronous subprocess crashes and connection timeouts (flutter/flutter#186964)
2026-05-26 bkonyi@google.com [pubspec] Bump Dart SDK constraint to ^3.13.0 (flutter/flutter#186957)
2026-05-26 engine-flutter-autoroll@skia.org Roll Dart SDK from 7eb54169841d to 00e625453c43 (1 revision) (flutter/flutter#187086)
2026-05-26 bdero@google.com [Impeller] Retire Y-coord-scale plumbing by flipping GLES at the vertex stage (flutter/flutter#186556)
2026-05-26 engine-flutter-autoroll@skia.org Roll Skia from f4f294bdf98d to 0442274cc696 (2 revisions) (flutter/flutter#187079)
2026-05-26 kevmoo@users.noreply.github.com [flutter_tools] Fix version cache poisoning from git environment variables (flutter/flutter#186595)
2026-05-26 bkonyi@google.com [Tool] Handle DTD connection failures gracefully in widget-preview (flutter/flutter#186952)
2026-05-25 engine-flutter-autoroll@skia.org Roll Skia from 9d1adb5f2427 to f4f294bdf98d (1 revision) (flutter/flutter#187056)
2026-05-25 engine-flutter-autoroll@skia.org Roll Skia from 4dd78179e6ec to 9d1adb5f2427 (1 revision) (flutter/flutter#187048)
2026-05-25 engine-flutter-autoroll@skia.org Roll Skia from 1f26101197bf to 4dd78179e6ec (4 revisions) (flutter/flutter#187044)
2026-05-24 engine-flutter-autoroll@skia.org Roll Skia from bbe9ccc2bdbf to 1f26101197bf (1 revision) (flutter/flutter#187016)
2026-05-24 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from nsgcNDlZOuweOvy3Q... to Itd2Jq_ZIABH2rW7B... (flutter/flutter#187032)
2026-05-23 engine-flutter-autoroll@skia.org Roll Dart SDK from 7e0f28eb5315 to 7eb54169841d (1 revision) (flutter/flutter#187005)
2026-05-23 engine-flutter-autoroll@skia.org Roll Dart SDK from 90e55fa88456 to 7e0f28eb5315 (1 revision) (flutter/flutter#186990)
2026-05-23 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 6T6BY9PTftoG3vP_1... to nsgcNDlZOuweOvy3Q... (flutter/flutter#186984)
2026-05-23 chris@bracken.jp iOS] Migrate VSyncClient to a pure Obj-C implementation (#186166) (flutter/flutter#186935)
2026-05-23 30870216+gaaclarke@users.noreply.github.com Disables embedder_tests.cm for fuchsia (flutter/flutter#186969)
2026-05-23 engine-flutter-autoroll@skia.org Roll Dart SDK from b8414c46f6c7 to 90e55fa88456 (2 revisions) (flutter/flutter#186977)
2026-05-22 engine-flutter-autoroll@skia.org Roll Skia from 6fdb013d1953 to bbe9ccc2bdbf (1 revision) (flutter/flutter#186980)
2026-05-22 mdebbar@google.com [web] Fix cutoff text in WebParagraph (flutter/flutter#186819)
2026-05-22 1961493+harryterkelsen@users.noreply.github.com fix(web): Removes the iterative downscaling hack (flutter/flutter#186914)
2026-05-22 30870216+gaaclarke@users.noreply.github.com opts the linux embedder into sdf rendering (flutter/flutter#186909)
2026-05-22 engine-flutter-autoroll@skia.org Roll Skia from dae8778ca40d to 6fdb013d1953 (5 revisions) (flutter/flutter#186970)
2026-05-22 dacoharkes@google.com Fix hooks inputs outputs rebuilt (flutter/flutter#186701)
2026-05-22 30870216+gaaclarke@users.noreply.github.com adds linux impeller integration test for external textures (flutter/flutter#186759)
2026-05-22 kevmoo@users.noreply.github.com fix(flutter_tools): defensively catch DWDS unregistered service extension errors (flutter/flutter#186896)
2026-05-22 bdero@google.com [Impeller] Add golden harness support to the renderer test layer (flutter/flutter#186735)
2026-05-22 mdebbar@google.com [web] Remove image codecs from canvaskit_chromium (flutter/flutter#178133)
2026-05-22 30870216+gaaclarke@users.noreply.github.com opts all macos into wide gamut (flutter/flutter#186277)
2026-05-22 engine-flutter-autoroll@skia.org Roll Skia from 356185490a75 to dae8778ca40d (9 revisions) (flutter/flutter#186949)
2026-05-22 1598289+lukemmtt@users.noreply.github.com Filter out SwiftPM schemes when fetching schemes (flutter/flutter#186006)
2026-05-22 engine-flutter-autoroll@skia.org Roll Packages from 3754d04 to 69cf959 (1 revision) (flutter/flutter#186950)
2026-05-22 engine-flutter-autoroll@skia.org Roll Dart SDK from eca46bec956d to b8414c46f6c7 (2 revisions) (flutter/flutter#186944)
2026-05-22 30870216+gaaclarke@users.noreply.github.com Saves a DeviceHolderVK with the CommandPoolVK (flutter/flutter#186749)
2026-05-22 engine-flutter-autoroll@skia.org Roll Dart SDK from e0d509fd676e to eca46bec956d (1 revision) (flutter/flutter#186922)
2026-05-22 bkonyi@google.com [ Tool ] Stop generating widget preview scaffold under $TMP (flutter/flutter#186476)
2026-05-21 737941+loic-sharma@users.noreply.github.com Fix typo in StretchingOverscrollIndicator docs (flutter/flutter#186897)
2026-05-21 engine-flutter-autoroll@skia.org Roll Dart SDK from 28c7cb5a8e8d to e0d509fd676e (1 revision) (flutter/flutter#186903)
2026-05-21 jason-simmons@users.noreply.github.com Fix some issues in the integration between EmbedderExternalViewEmbedder and Impeller (flutter/flutter#184905)
2026-05-21 jason-simmons@users.noreply.github.com Fix a potential buffer overflow in the animated PNG decoder when parsing malformed fdAT chunks (flutter/flutter#186700)
2026-05-21 engine-flutter-autoroll@skia.org Roll Skia from 2ff20950975d to 356185490a75 (5 revisions) (flutter/flutter#186892)
2026-05-21 flar@google.com Add primitive shadows to rendering benchmark (flutter/flutter#186779)
2026-05-21 15619084+vashworth@users.noreply.github.com Move prefetchSwiftPackages to be per platform (flutter/flutter#186468)
2026-05-21 okorohelijah@google.com Upgrade iOS version (flutter/flutter#186889)
...
github-merge-queue Bot pushed a commit that referenced this pull request Jun 11, 2026
…#187400)

Fixes a performance regression introduced in #186595 where healthy SDK
installations on developer or PR branches (detected as '[user-branch]')
were treated as suspicious, forcing a slow Git fallback on every
command.

1. Refined `isSuspicious` to check for non-standard `repositoryUrl`
instead of `[user-branch]` channel.
2. Improved `repositoryUrl` detection to fallback to `origin` remote if
no upstream is configured, ensuring healthy dev branches can resolve a
standard remote.
3. Fixed `isGitRepo` check to support Git worktrees where `.git` is a
file.
4. Updated and fixed associated unit tests in `version_test.dart`.

---------

Co-authored-by: Kevin Moore <kevmoo@users.noreply.github.com>
via-guy pushed a commit to via-guy/flutter that referenced this pull request Jun 26, 2026
…ables (flutter#186595)

Fixes flutter#180421
Fixes flutter#178160

Addresses issues where running flutter inside git hooks
would cause the tool to incorrectly cache version info from the user's
project instead of the SDK.

1. Added environment filtering to strip inherited GIT_* variables from
   SDK-related git commands, ensuring accurate version detection.
2. Refined FlutterVersion factory to only fall back to git if the
   cached version looks suspicious (e.g. unknown channel), avoiding
   startup latency for healthy installations.
3. Updated ensureVersionFile to proactively sync the cache when called.
4. Improved flutter doctor messages with hints on how to reset a
   corrupted version cache.
5. Updated Git.logSync to support passing custom environments.

---------

Co-authored-by: Ben Konyi <bkonyi@google.com>
via-guy pushed a commit to via-guy/flutter that referenced this pull request Jun 26, 2026
…flutter#187400)

Fixes a performance regression introduced in flutter#186595 where healthy SDK
installations on developer or PR branches (detected as '[user-branch]')
were treated as suspicious, forcing a slow Git fallback on every
command.

1. Refined `isSuspicious` to check for non-standard `repositoryUrl`
instead of `[user-branch]` channel.
2. Improved `repositoryUrl` detection to fallback to `origin` remote if
no upstream is configured, ensuring healthy dev branches can resolve a
standard remote.
3. Fixed `isGitRepo` check to support Git worktrees where `.git` is a
file.
4. Updated and fixed associated unit tests in `version_test.dart`.

---------

Co-authored-by: Kevin Moore <kevmoo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

4 participants