Skip to content

Throw ToolExit when flutter downgrade receives positional arguments#183375

Merged
auto-submit[bot] merged 5 commits into
flutter:masterfrom
NamanGoyalK:fix-issue-182820
Mar 19, 2026
Merged

Throw ToolExit when flutter downgrade receives positional arguments#183375
auto-submit[bot] merged 5 commits into
flutter:masterfrom
NamanGoyalK:fix-issue-182820

Conversation

@NamanGoyalK

Copy link
Copy Markdown
Contributor

Description

The flutter downgrade command currently ignores positional arguments (such as a specific version number) and silently falls back to its default behavior. This leads to a confusing developer experience when a user assumes they can type flutter downgrade 3.19.0.

This PR intercepts unexpected positional arguments in DowngradeCommand and throws a clear ToolExit. It instructs the user that the command does not support specifying a version and provides the link to the official documentation for switching Flutter versions using git checkout.

Issues

Fixes #182820

Tests

  • Added a hermetic test in downgrade_test.dart to verify that a ToolExit is thrown with the correct exit code and error message when a positional argument is passed.

Pre-launch Checklist

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Mar 8, 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 modifies the flutter downgrade command to handle unexpected positional arguments. Previously, these arguments were silently ignored. Now, if a positional argument is provided, the command will exit with a ToolExit, displaying a clear error message that explains the correct usage and provides a link to the documentation for switching Flutter versions. A corresponding test has been added to verify this new behavior.

Comment thread packages/flutter_tools/test/commands.shard/hermetic/downgrade_test.dart Outdated
Comment thread packages/flutter_tools/lib/src/commands/downgrade.dart Outdated
bkonyi
bkonyi previously approved these changes Mar 16, 2026

@bkonyi bkonyi 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.

LGTM! We'll need one more reviewer on this before it can land.

@bkonyi bkonyi requested a review from chingjun March 16, 2026 15:46
@bkonyi bkonyi added the CICD Run CI/CD label Mar 16, 2026
@bkonyi bkonyi added CICD Run CI/CD and removed CICD Run CI/CD labels Mar 16, 2026
Comment thread packages/flutter_tools/lib/src/commands/downgrade.dart Outdated
@github-actions github-actions Bot removed the CICD Run CI/CD label Mar 19, 2026
@chingjun chingjun added the CICD Run CI/CD label Mar 19, 2026
@bkonyi

bkonyi commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

LGTM! Thanks for the contribution!

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 19, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue Mar 19, 2026
Merged via the queue into flutter:master with commit fec2d76 Mar 19, 2026
150 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 19, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 19, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 19, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 21, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 21, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 21, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 22, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 22, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 23, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 23, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 23, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 23, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 24, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 24, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 24, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 24, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 24, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 24, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 25, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 25, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 25, 2026
mboetger pushed a commit to mboetger/flutter that referenced this pull request Mar 26, 2026
…lutter#183375)

## Description
The `flutter downgrade` command currently ignores positional arguments
(such as a specific version number) and silently falls back to its
default behavior. This leads to a confusing developer experience when a
user assumes they can type `flutter downgrade 3.19.0`.

This PR intercepts unexpected positional arguments in `DowngradeCommand`
and throws a clear `ToolExit`. It instructs the user that the command
does not support specifying a version and provides the link to the
official documentation for switching Flutter versions using `git
checkout`.

## Issues
Fixes flutter#182820

## Tests
* Added a hermetic test in `downgrade_test.dart` to verify that a
`ToolExit` is thrown with the correct exit code and error message when a
positional argument is passed.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [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] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
ahmedsameha1 pushed a commit to ahmedsameha1/flutter that referenced this pull request Apr 14, 2026
…lutter#183375)

## Description
The `flutter downgrade` command currently ignores positional arguments
(such as a specific version number) and silently falls back to its
default behavior. This leads to a confusing developer experience when a
user assumes they can type `flutter downgrade 3.19.0`.

This PR intercepts unexpected positional arguments in `DowngradeCommand`
and throws a clear `ToolExit`. It instructs the user that the command
does not support specifying a version and provides the link to the
official documentation for switching Flutter versions using `git
checkout`.

## Issues
Fixes flutter#182820

## Tests
* Added a hermetic test in `downgrade_test.dart` to verify that a
`ToolExit` is thrown with the correct exit code and error message when a
positional argument is passed.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [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] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
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.

Flutter downgrade 3.19.0 doesn't work

3 participants