Skip to content

[ Widget Preview ] Don't try to instantiate invalid @Preview() applications #173984

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 18, 2025

Conversation

bkonyi
Copy link
Contributor

@bkonyi bkonyi commented Aug 18, 2025

Applying @Preview() to an invalid AST node shouldn't cause the preview environment to throw an exception due to invalid generated code.

This change adds some additional checks to ensure that invalid @Preview() applications are ignored.

Related issue: #173959
Related stable hotfix: #173979

…ications

Applying `@Preview()` to an invalid AST node shouldn't cause the preview
environment to throw an exception due to invalid generated code.

This change adds some additional checks to ensure that invalid
`@Preview()` applications are ignored.

Related issue: #173959
Related stable hotfix: #173979
@bkonyi bkonyi requested a review from matanlurey August 18, 2025 18:47
@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 18, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

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 enhances the robustness of widget preview detection by adding checks to ignore invalid @Preview() applications, preventing exceptions from invalid generated code. The changes are logical and well-tested. I've added a couple of suggestions to further improve the resilience of the AST parsing by handling nullable return types and unexpected type annotations more safely, which aligns with the goal of this PR.

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 18, 2025
Copy link
Contributor

auto-submit bot commented Aug 18, 2025

autosubmit label was removed for flutter/flutter/173984, because - The status or check suite Mac tool_integration_tests_4_5 has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 18, 2025
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 18, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Aug 18, 2025
Merged via the queue into master with commit 8b2b9d7 Aug 18, 2025
152 checks passed
@auto-submit auto-submit bot deleted the fix_173959 branch August 18, 2025 20:32
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 18, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 19, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Aug 19, 2025
flutter/flutter@2265d94...e65380a

2025-08-19 engine-flutter-autoroll@skia.org Roll Dart SDK from 502455ee300b to 9105d946af95 (3 revisions) (flutter/flutter#174002)
2025-08-18 matanlurey@users.noreply.github.com Add `open_jdk` to `Linux analyze` (flutter/flutter#173988)
2025-08-18 magder@google.com Add "team-ios" label to iOS team triage query (flutter/flutter#173997)
2025-08-18 1063596+reidbaker@users.noreply.github.com Migrate deeplink json creation to public AGP api (flutter/flutter#173794)
2025-08-18 bkonyi@google.com [ Widget Preview ] Don't crash when directory watcher restarts on Windows (flutter/flutter#173987)
2025-08-18 bkonyi@google.com [ Widget Preview ] Don't try to instantiate invalid `@Preview()` applications (flutter/flutter#173984)
2025-08-18 737941+loic-sharma@users.noreply.github.com Explain how to run Google Test tests directly (flutter/flutter#173978)
2025-08-18 58529443+srujzs@users.noreply.github.com [flutter_tools] Use DWDS 25.0.1 (flutter/flutter#173777)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC bmparr@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
WillBLogical pushed a commit to WillBLogical/packages that referenced this pull request Aug 20, 2025
…#9850)

flutter/flutter@2265d94...e65380a

2025-08-19 engine-flutter-autoroll@skia.org Roll Dart SDK from 502455ee300b to 9105d946af95 (3 revisions) (flutter/flutter#174002)
2025-08-18 matanlurey@users.noreply.github.com Add `open_jdk` to `Linux analyze` (flutter/flutter#173988)
2025-08-18 magder@google.com Add "team-ios" label to iOS team triage query (flutter/flutter#173997)
2025-08-18 1063596+reidbaker@users.noreply.github.com Migrate deeplink json creation to public AGP api (flutter/flutter#173794)
2025-08-18 bkonyi@google.com [ Widget Preview ] Don't crash when directory watcher restarts on Windows (flutter/flutter#173987)
2025-08-18 bkonyi@google.com [ Widget Preview ] Don't try to instantiate invalid `@Preview()` applications (flutter/flutter#173984)
2025-08-18 737941+loic-sharma@users.noreply.github.com Explain how to run Google Test tests directly (flutter/flutter#173978)
2025-08-18 58529443+srujzs@users.noreply.github.com [flutter_tools] Use DWDS 25.0.1 (flutter/flutter#173777)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC bmparr@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
gmackall pushed a commit to gmackall/flutter that referenced this pull request Aug 21, 2025
…ications (flutter#173984)

Applying `@Preview()` to an invalid AST node shouldn't cause the preview
environment to throw an exception due to invalid generated code.

This change adds some additional checks to ensure that invalid
`@Preview()` applications are ignored.

Related issue: flutter#173959
Related stable hotfix: flutter#173979
SydneyBao pushed a commit to SydneyBao/flutter that referenced this pull request Aug 22, 2025
…ications (flutter#173984)

Applying `@Preview()` to an invalid AST node shouldn't cause the preview
environment to throw an exception due to invalid generated code.

This change adds some additional checks to ensure that invalid
`@Preview()` applications are ignored.

Related issue: flutter#173959
Related stable hotfix: flutter#173979
SydneyBao pushed a commit to SydneyBao/flutter that referenced this pull request Aug 22, 2025
…ications (flutter#173984)

Applying `@Preview()` to an invalid AST node shouldn't cause the preview
environment to throw an exception due to invalid generated code.

This change adds some additional checks to ensure that invalid
`@Preview()` applications are ignored.

Related issue: flutter#173959
Related stable hotfix: flutter#173979
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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