Sitelet https://github.com/flutter/flutter/pull/191359
Skip to content

[flutter_tools] Move plugin validation out of asserts - #191359

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
bkonyi:investigation/issue-67241
Aug 19, 2026
Merged

auto-submit[bot] merged 2 commits into
flutter:masterfrom
bkonyi:investigation/issue-67241

Conversation

@bkonyi

@bkonyi bkonyi commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Platform plugin fromYaml factories in platform_plugins.dart (AndroidPlugin, IOSPlugin, MacOSPlugin, WindowsPlugin, and LinuxPlugin) previously performed validation inside assert statements. When Flutter tools runs in release mode (assertions disabled), calling these factories directly could bypass validation and return invalid plugin instances rather than surfacing a clean tool exit.

This PR:

  1. Replaces assert(validate(yaml)) in all platform plugin fromYaml factories with explicit validation checks that call throwToolExit.
  2. Includes the plugin name in the exit error message (e.g. Invalid "android" plugin specification for plugin "$name".).
  3. Adds automated unit tests in plugins_test.dart verifying that fromYaml throws ToolExit when passed invalid YAML.

Fixes #67241

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 provide.
  • 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.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

bkonyi added 2 commits August 18, 2026 23:18
Platform plugin `fromYaml` factories were performing validation inside
`assert` statements. These are stripped in release mode, leaving the
factories without validation for users.

Replace the asserts with explicit checks that throw `ToolExit`.
…ation errors

Include the plugin `$name` in the `ToolExit` error message when
validating `fromYaml` in `AndroidPlugin`, `IOSPlugin`, `MacOSPlugin`,
`WindowsPlugin`, and `LinuxPlugin`.
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 19, 2026
@bkonyi bkonyi added the CICD Run CI/CD label Aug 19, 2026
@bkonyi
bkonyi marked this pull request as ready for review August 19, 2026 17:07
@bkonyi
bkonyi requested a review from dcharkes August 19, 2026 17:07

@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 replaces assertions with explicit validation checks in the fromYaml factories of AndroidPlugin, IOSPlugin, MacOSPlugin, WindowsPlugin, and LinuxPlugin, throwing a ToolExit with a descriptive error message when validation fails. Corresponding unit tests have been added to verify this validation behavior across all supported platforms. There are no review comments, and I have no feedback to provide.

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.

Plugin parsing and validation is done in assert statements and discarded for most users

2 participants