Skip to content

Conversation

@bkonyi
Copy link
Contributor

@bkonyi bkonyi commented Aug 18, 2025

Fixes #173959

This is a top-10 crasher on 3.35.{0,1}, but the underlying preview detection logic has been completely rewritten since the stable branch cut.

@flutter-dashboard
Copy link

This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter.

Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed.

@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 18, 2025
@bkonyi bkonyi requested a review from matanlurey August 18, 2025 18:14
@bkonyi bkonyi marked this pull request as ready for review August 18, 2025 18:14
@bkonyi bkonyi added cp: beta cherry pick this pull request to beta release candidate branch cp: stable cherry pick this pull request to stable release candidate branch labels 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 addresses a null assertion crash that occurs when @Preview() is applied to invalid code elements. The fix involves adding validation checks to ensure that previews are only generated for valid targets (e.g., functions without required parameters and with appropriate return types). A crucial null check is also added before attempting to register a preview, which resolves the crash. The changes are supported by a new utility method and a comprehensive new test suite that covers various invalid usage scenarios. The implementation is solid and effectively solves the reported issue. I have one minor suggestion to improve code conciseness.

bkonyi added a commit that referenced this pull request Aug 18, 2025
…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
github-merge-queue bot pushed a commit that referenced this pull request Aug 18, 2025
…ications (#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: #173959
Related stable hotfix: #173979
@matanlurey matanlurey added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 19, 2025
@auto-submit auto-submit bot merged commit e20f7cf into flutter-3.35-candidate.0 Aug 19, 2025
146 checks passed
@auto-submit auto-submit bot deleted the cp_fix_issue_173959 branch August 19, 2025 18:36
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
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 26, 2025
mboetger pushed a commit to mboetger/flutter that referenced this pull request Sep 18, 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
korca0220 pushed a commit to korca0220/flutter that referenced this pull request Sep 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
Jaineel-Mamtora pushed a commit to Jaineel-Mamtora/flutter_forked that referenced this pull request Sep 24, 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
lucaantonelli pushed a commit to lucaantonelli/flutter that referenced this pull request Nov 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App cp: beta cherry pick this pull request to beta release candidate branch cp: stable cherry pick this pull request to stable release candidate branch 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