Skip to content

[flutter_tools] Remove AzureDetector IMDS probe from BotDetector - #194530

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
kevmoo:issue-194405
Oct 16, 2026
Merged

auto-submit[bot] merged 2 commits into
flutter:masterfrom
kevmoo:issue-194405

Conversation

@kevmoo

@kevmoo kevmoo commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

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.

Part of #194405

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
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Oct 16, 2026
…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
kevmoo marked this pull request as ready for review October 16, 2026 05:17
@kevmoo
kevmoo requested a review from chingjun October 16, 2026 05:19

@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 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 chingjun added the CICD Run CI/CD label Oct 16, 2026
@kevmoo kevmoo added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 16, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Oct 16, 2026
Merged via the queue into flutter:master with commit e6a0821 Oct 16, 2026
31 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 16, 2026
@kevmoo
kevmoo deleted the issue-194405 branch October 17, 2026 01:21
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants