Repository navigation
[flutter_tools] Remove AzureDetector IMDS probe from BotDetector - #194530
Merged
Merged
Conversation
Remove `AzureDetector` (`http://169.254.169.254/metadata/instance`) and persistent `is-bot` caching (`PersistentToolState.isRunningOnBot` / `setIsRunningOnBot`) from `BotDetector`, relying strictly on deterministic CI environment variables. - Remove IMDS probe and disk cache (`bot_detector.dart`, `persistent_tool_state.dart`): Eliminates the link-local HTTP probe on tool startup, prevents cloud developer workstations on Azure/GCE/AWS from being permanently misclassified as bots in `.flutter_tool_state`, and removes unused `httpClientFactory` and `persistentToolState` parameters from `BotDetector`. - Tighten `BOT` and `CI` environment checks (`bot_detector.dart`): Treat `BOT=false` and `BOT=0` as explicit non-bot overrides, require `CI` to be non-empty and not `'false'` or `'0'`, accept `BOT=true` or `BOT=1`, and check `AZURE_HTTP_USER_AGENT` alongside `TF_BUILD` (matching `dartdev`). - Keep `Future<bool> get isRunningOnBot` async to avoid churn across existing production `await` sites and `FakeBotDetector`. Fixes flutter#194405
…xture Trim and lowercase `BOT` and `CI` in `BotDetector.isRunningOnBot` so `CI=False` (e.g. PowerShell `$false`) is not misclassified as a bot, and remove the unused `FakeStdio` fixture from `bot_detector_test.dart`.
kevmoo
marked this pull request as ready for review
October 16, 2026 05:17
Contributor
There was a problem hiding this comment.
Code Review
This pull request simplifies the BotDetector class by removing its dependencies on HttpClientFactory, PersistentToolState, and the AzureDetector class. Azure environment detection is now performed by checking the AZURE_HTTP_USER_AGENT environment variable instead of making an HTTP request to the Azure metadata service. Additionally, the isRunningOnBot property and its caching mechanism have been removed from PersistentToolState. The corresponding unit tests have been updated to reflect these changes. I have no feedback to provide.
chingjun
approved these changes
Oct 16, 2026
This was referenced Oct 17, 2026
suryaKommana2662
pushed a commit
to suryaKommana2662/flutter
that referenced
this pull request
Oct 29, 2026
…tter#194530) Remove `AzureDetector` (`http://169.254.169.254/metadata/instance`) and persistent `is-bot` caching (`PersistentToolState.isRunningOnBot` / `setIsRunningOnBot`) from `BotDetector`, relying strictly on deterministic CI environment variables. - **Remove IMDS probe and disk cache (`bot_detector.dart`, `persistent_tool_state.dart`)**: Eliminates the link-local HTTP probe on tool startup, prevents cloud developer workstations on Azure/GCE/AWS from being permanently misclassified as bots in `.flutter_tool_state`, and removes unused `httpClientFactory` and `persistentToolState` parameters from `BotDetector`. - **Tighten `BOT` and `CI` environment checks (`bot_detector.dart`)**: Treat `BOT=false` and `BOT=0` as explicit non-bot overrides, require `CI` to be non-empty and not `'false'` or `'0'`, accept `BOT=true` or `BOT=1`, and check `AZURE_HTTP_USER_AGENT` alongside `TF_BUILD` (matching `dartdev`). - **Async getter retention**: `Future<bool> get isRunningOnBot` is intentionally kept async (`Future<bool>`) in this PR to avoid churn across the 12 production `await` sites and `FakeBotDetector` in tests; once `package:unified_analytics` rolls with `Analytics.isBot(Map<String, String> environment)` (tracked in dart-lang/tools#2672 / dart-lang/tools#2687), a follow-up PR for flutter#194405 can delegate directly or simplify callers if desired. Part of flutter#194405
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.
Remove
AzureDetector(http://169.254.169.254/metadata/instance) and persistentis-botcaching (PersistentToolState.isRunningOnBot/setIsRunningOnBot) fromBotDetector, relying strictly on deterministic CI environment variables.bot_detector.dart,persistent_tool_state.dart): Eliminates the link-local HTTP probe on tool startup, prevents cloud developer workstations on Azure/GCE/AWS from being permanently misclassified as bots in.flutter_tool_state, and removes unusedhttpClientFactoryandpersistentToolStateparameters fromBotDetector.BOTandCIenvironment checks (bot_detector.dart): TreatBOT=falseandBOT=0as explicit non-bot overrides, requireCIto be non-empty and not'false'or'0', acceptBOT=trueorBOT=1, and checkAZURE_HTTP_USER_AGENTalongsideTF_BUILD(matchingdartdev).Future<bool> get isRunningOnBotis intentionally kept async (Future<bool>) in this PR to avoid churn across the 12 productionawaitsites andFakeBotDetectorin tests; oncepackage:unified_analyticsrolls withAnalytics.isBot(Map<String, String> environment)(tracked in [unified_analytics] Add shared isBot helper and is_bot user property dart-lang/tools#2672 / [unified_analytics] Fix Cursor agent check, default agent & add isBot dart-lang/tools#2687), a follow-up PR for [flutter_tools] Remove AzureDetector IMDS probe from BotDetector #194405 can delegate directly or simplify callers if desired.Part of #194405