Skip to content

[flutter_tools] Add --[no-]extensions and FLUTTER_NO_EXTENSIONS safe mode - #194771

Merged
auto-submit[bot] merged 9 commits into
flutter:masterfrom
bkonyi:ft-ext-phase01b-safe-mode
Oct 21, 2026
Merged

auto-submit[bot] merged 9 commits into
flutter:masterfrom
bkonyi:ft-ext-phase01b-safe-mode

Conversation

@bkonyi

@bkonyi bkonyi commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Add the global --[no-]extensions CLI flag and FLUTTER_NO_EXTENSIONS=1 environment variable to bypass tool extension discovery and isolate spawning, and require FeatureFlags on ExtensionManager.

Stack

Part of #190755

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • All existing and new tests are passing.

…mode

- Add the global --[no-]extensions CLI flag and FLUTTER_NO_EXTENSIONS=1 environment variable to bypass tool extension discovery and isolate spawning.
- Make FeatureFlags required on ExtensionManager and wire isSafeMode through ToolDependencies.bootstrap and FlutterFeatureFlags.isEnabled.
…date top-level flag collection

- Remove isToolExtensionsEnabledOverride from runner.dart, ToolDependencies.bootstrap, and FlutterFeatureFlags, reading --[no-]extensions from globalResults in ConfigCommand and DoctorCommand.
- Consolidate top-level CLI flag collection and option token skipping in FlutterCommandRunner.
Consolidate --[no-]extensions flag evaluation directly into
_findTargetCommand and remove _evaluateTopLevelFlag.

Previously, FlutterCommandRunner ran two separate traversals over raw
CLI arguments before dynamic option initialization: _evaluateTopLevelFlag
and _findTargetCommand. Furthermore, because _evaluateTopLevelFlag stopped
at the first command token, passing --no-extensions after the command
(e.g., flutter config --no-extensions) did not disable extensions during
dynamic option initialization.

_findTargetCommand now returns a ({Command<void>? command, bool extensionsEnabled})
record in a single pass while respecting option values via _optionTokenCount.
Also upgrade _optionTokenCount to use findByNameOrAlias and findByAbbreviation.

Part of flutter#190755
@bkonyi
bkonyi marked this pull request as ready for review October 21, 2026 17:52

@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 a safe mode for Flutter tool extensions, allowing them to be disabled via the FLUTTER_NO_EXTENSIONS environment variable or the --no-extensions command-line flag. It updates FlutterCommandRunner to pre-parse arguments and disable the ExtensionManager before dynamic options are initialized. Feedback on the changes suggests supporting inline boolean flag formats (such as --extensions=false) during pre-parsing, ensuring global options are correctly resolved when parsing subcommand arguments, and adding an assertion to enforce that ExtensionManager.disable() is called before initialization starts.

…rt disable lifecycle

In _optionTokenCount, fall back to checking the root argParser when an
option is not found in the current subcommand parser. This ensures global
options with value arguments passed after a subcommand consume their
arguments properly rather than treating the value as a subcommand name.

Also add an assertion to ExtensionManager.disable() to ensure disable()
cannot be called after initialization has started.

Part of flutter#190755
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 21, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Oct 21, 2026
Merged via the queue into flutter:master with commit b26dfbf Oct 21, 2026
23 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 21, 2026
LongCatIsLooong pushed a commit to LongCatIsLooong/flutter that referenced this pull request Oct 22, 2026
…mode (flutter#194771)

Add the global `--[no-]extensions` CLI flag and
`FLUTTER_NO_EXTENSIONS=1` environment variable to bypass tool extension
discovery and isolate spawning, and require `FeatureFlags` on
`ExtensionManager`.

### Stack
- **PR 1A (parallel off `master`)**:
flutter#194590
(`ft-ext-phase01-03-project-discovery`)
- **PR 1B (this PR)**: flutter#194771
(`ft-ext-phase01b-safe-mode`)
- **PR 1C (stacked on 1A)**:
flutter#194772
(`ft-ext-phase01c-finder-and-compiler`)
- **PR 1D (stacked on 1B + 1C)**:
flutter#194774
(`ft-ext-phase01d-dynamic-discovery-wiring`)

Part of flutter#190755

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] All existing and new tests are passing.
suryaKommana2662 pushed a commit to suryaKommana2662/flutter that referenced this pull request Oct 29, 2026
…mode (flutter#194771)

Add the global `--[no-]extensions` CLI flag and
`FLUTTER_NO_EXTENSIONS=1` environment variable to bypass tool extension
discovery and isolate spawning, and require `FeatureFlags` on
`ExtensionManager`.

### Stack
- **PR 1A (parallel off `master`)**:
flutter#194590
(`ft-ext-phase01-03-project-discovery`)
- **PR 1B (this PR)**: flutter#194771
(`ft-ext-phase01b-safe-mode`)
- **PR 1C (stacked on 1A)**:
flutter#194772
(`ft-ext-phase01c-finder-and-compiler`)
- **PR 1D (stacked on 1B + 1C)**:
flutter#194774
(`ft-ext-phase01d-dynamic-discovery-wiring`)

Part of flutter#190755

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] All existing and new tests are passing.
suryaKommana2662 pushed a commit to suryaKommana2662/flutter that referenced this pull request Oct 29, 2026
….spawnUri support (flutter#194590)

Introduce `ExtensionPackageConfig` in `package:flutter_tools_core` for
parsing `extension/flutter_tools/config.yaml` manifests,
`Isolate.spawnUri` entrypoint support in `ToolExtensionEntryPoint.run`
and `package:flutter_tools_extension_linux_prototype`, and
`ExtensionConnection.spawnUri` (with `expectedConfig` capability
validation) in `flutter_tools`.

### Stack
- **PR 1A (this PR)**: flutter#194590
(`ft-ext-phase01-03-project-discovery`)
- **PR 1B (merged)**: flutter#194771
(`ft-ext-phase01b-safe-mode`)
- **PR 1C (stacked on 1A)**:
flutter#194772
(`ft-ext-phase01c-finder-and-compiler`)
- **PR 1D (stacked on 1C)**:
flutter#194774
(`ft-ext-phase01d-dynamic-discovery-wiring`)

Part of flutter#190755

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] All existing and new tests are passing.
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