Skip to content

[flutter_tools] Handle null version gracefully in CachedArtifact and MaterialFonts - #191494

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

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

Conversation

@bkonyi

@bkonyi bkonyi commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

When artifact version files (such as bin/internal/material_fonts.version) are missing or cannot be resolved, CachedArtifact.version evaluates to null. Previously, CachedArtifact.update invoked updateInner before checking if version was null, causing MaterialFonts.updateInner (and other artifact subclasses) to evaluate version! and throw an unhandled TypeError / _CastError with Null check operator used on a null value.

This change:

  1. Returns early with a warning in CachedArtifact.update before attempting updateInner or writing stamps when version == null.
  2. Guards against version == null in MaterialFonts, GradleWrapper, and FlutterRunnerDebugSymbols.
  3. Adds an automated regression test in cache_test.dart.

Fixes #90092

…MaterialFonts

When artifact version files (such as bin/internal/material_fonts.version)
are missing or cannot be resolved, CachedArtifact.version evaluates to null.
Previously, CachedArtifact.update invoked updateInner before checking if
version was null, causing MaterialFonts.updateInner (and other artifact
subclasses) to evaluate version! and throw an unhandled CastError / TypeError
with 'Null check operator used on a null value'.

This change:
1. Returns early with a warning in CachedArtifact.update before attempting
   updateInner or writing stamps when version is null.
2. Guards against version == null in MaterialFonts, GradleWrapper, and
   FlutterRunnerDebugSymbols.
3. Adds an automated regression test in cache_test.dart.

Fixes flutter#90092
@bkonyi bkonyi added the CICD Run CI/CD label Aug 21, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 21, 2026
@bkonyi
bkonyi marked this pull request as ready for review August 21, 2026 19:29

@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 updates the artifact caching logic to return early when an artifact's version is null, preventing unnecessary updates. It also adds corresponding null checks in several CachedArtifact subclasses (MaterialFonts, GradleWrapper, and FlutterRunnerDebugSymbols) and introduces a new test case. The review feedback points out that because the base class CachedArtifact.update now handles the null check and returns early, the local null checks added to the subclasses' updateInner methods are redundant and can be simplified.

Comment thread packages/flutter_tools/lib/src/flutter_cache.dart Outdated
Comment thread packages/flutter_tools/lib/src/flutter_cache.dart Outdated
Comment thread packages/flutter_tools/lib/src/flutter_cache.dart Outdated
…bclasses

CachedArtifact.update guarantees that updateInner is only called when version is
non-null. Subclasses can use version! directly without redundant local null checks.
@bkonyi
bkonyi requested a review from chingjun August 21, 2026 19:54
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 24, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Aug 24, 2026
Merged via the queue into flutter:master with commit 0c0d059 Aug 24, 2026
23 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 24, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Aug 26, 2026
Roll Flutter from 9a8278982588 to 15d8908addf6 (37 revisions)

flutter/flutter@9a82789...15d8908

2026-08-25 [email protected] Roll Packages from df2ba94 to 740f093 (17 revisions) (flutter/flutter#191734)
2026-08-25 [email protected] [record_use] Remove const_finder (flutter/flutter#191702)
2026-08-25 [email protected] Warn when SwiftPM is disabled (flutter/flutter#188695)
2026-08-25 [email protected] Roll Skia from b1a31575c373 to 480540178356 (1 revision) (flutter/flutter#191723)
2026-08-25 [email protected] Roll pub packages (flutter/flutter#191726)
2026-08-25 [email protected] Roll Skia from bfa276ed9ac5 to b1a31575c373 (1 revision) (flutter/flutter#191717)
2026-08-25 [email protected] Roll Dart SDK from 0818e6dc28cc to 8996935d3d0a (2 revisions) (flutter/flutter#191706)
2026-08-25 [email protected] Roll Skia from 31799e707cd4 to bfa276ed9ac5 (1 revision) (flutter/flutter#191701)
2026-08-25 [email protected] iOS: Add null check for touch rate correction task runner (flutter/flutter#191641)
2026-08-25 [email protected] iOS: Add test for engineAllowHeadlessExecution (flutter/flutter#191635)
2026-08-25 [email protected] Roll Skia from cfae2af1bfeb to 31799e707cd4 (4 revisions) (flutter/flutter#191649)
2026-08-25 [email protected] Roll Dart SDK from 2b75c83ddd77 to 0818e6dc28cc (1 revision) (flutter/flutter#191643)
2026-08-25 [email protected] Roll Skia from 4a2fddefd3d8 to cfae2af1bfeb (1 revision) (flutter/flutter#191642)
2026-08-25 [email protected] Roll Skia from 256c15026b91 to 4a2fddefd3d8 (6 revisions) (flutter/flutter#191633)
2026-08-25 [email protected] Remove octant_offset_c uniform from ubersdf, reorder/document ubersdf uniforms (flutter/flutter#191597)
2026-08-25 [email protected] Roll Fuchsia Linux SDK from 8Xu4ujBJniC0nQGx3... to MstTWE1RDOT-RnrtH... (flutter/flutter#191621)
2026-08-25 [email protected] Roll Dart SDK from 78bbc37b6ff6 to 2b75c83ddd77 (3 revisions) (flutter/flutter#191614)
2026-08-24 [email protected] [flutter_tools] Fix $git typo in shared.bat to restore cache invalidation on Windows (flutter/flutter#191217)
2026-08-24 [email protected] Skip removed observers during app exit requests (flutter/flutter#190343)
2026-08-24 [email protected] [engine] Support UTF-8 paths in Windows filesystem and path APIs (flutter/flutter#191360)
2026-08-24 [email protected] Migrate ios driver tests batch 3 to simulators (flutter/flutter#191333)
2026-08-24 [email protected] Migrate texture example to material_ui (flutter/flutter#190673)
2026-08-24 [email protected] Remove outdated test todo about `dither` property of `Paint` (flutter/flutter#190936)
2026-08-24 [email protected] Add agent rule to prevent using material and cupertino in widget tests (flutter/flutter#191588)
2026-08-24 [email protected] [flutter_tools] Prevent crash when stdout is broken and print fails (flutter/flutter#191356)
2026-08-24 [email protected] Add FlViewRendererSubsurface (flutter/flutter#191389)
2026-08-24 [email protected] [Android] Inject `route` into manifest when specified on the command line in release mode (flutter/flutter#191328)
2026-08-24 [email protected] [AGP 9.1.0 Migration #3] Add buildModeFor overloads and wire Flutter dependencies through the new DSL (flutter/flutter#191218)
2026-08-24 [email protected] Roll Skia from 698c60bf58f1 to 256c15026b91 (1 revision) (flutter/flutter#191586)
2026-08-24 [email protected] On iOS 27+ devices, manually process lldb stops (flutter/flutter#191434)
2026-08-24 [email protected] [flutter_tools] Handle missing Xcode gracefully in getInfo and buildMacOS (flutter/flutter#191180)
2026-08-24 [email protected] [flutter_tools] Handle null version gracefully in CachedArtifact and MaterialFonts (flutter/flutter#191494)
2026-08-24 [email protected] [flutter_tools] Do not treat 'daemon' argument as daemon command in logger initialization (flutter/flutter#191442)
2026-08-24 [email protected] [flutter_tools] Resolve workspace root when running widget preview from member package (flutter/flutter#190952)
2026-08-24 [email protected] [native_assets] Roll native packages (flutter/flutter#191253)
2026-08-24 [email protected] [flutter_tools] Add --force flag to flutter channel (flutter/flutter#191579)
2026-08-24 [email protected] Roll Skia from 57968d087d18 to 698c60bf58f1 (1 revision) (flutter/flutter#191577)

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 [email protected],[email protected] 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

...
danielleon-cmd pushed a commit to victogomez-cs/packages-fork that referenced this pull request Aug 27, 2026
…r#12619)

Roll Flutter from 9a8278982588 to 15d8908addf6 (37 revisions)

flutter/flutter@9a82789...15d8908

2026-08-25 [email protected] Roll Packages from df2ba94 to 740f093 (17 revisions) (flutter/flutter#191734)
2026-08-25 [email protected] [record_use] Remove const_finder (flutter/flutter#191702)
2026-08-25 [email protected] Warn when SwiftPM is disabled (flutter/flutter#188695)
2026-08-25 [email protected] Roll Skia from b1a31575c373 to 480540178356 (1 revision) (flutter/flutter#191723)
2026-08-25 [email protected] Roll pub packages (flutter/flutter#191726)
2026-08-25 [email protected] Roll Skia from bfa276ed9ac5 to b1a31575c373 (1 revision) (flutter/flutter#191717)
2026-08-25 [email protected] Roll Dart SDK from 0818e6dc28cc to 8996935d3d0a (2 revisions) (flutter/flutter#191706)
2026-08-25 [email protected] Roll Skia from 31799e707cd4 to bfa276ed9ac5 (1 revision) (flutter/flutter#191701)
2026-08-25 [email protected] iOS: Add null check for touch rate correction task runner (flutter/flutter#191641)
2026-08-25 [email protected] iOS: Add test for engineAllowHeadlessExecution (flutter/flutter#191635)
2026-08-25 [email protected] Roll Skia from cfae2af1bfeb to 31799e707cd4 (4 revisions) (flutter/flutter#191649)
2026-08-25 [email protected] Roll Dart SDK from 2b75c83ddd77 to 0818e6dc28cc (1 revision) (flutter/flutter#191643)
2026-08-25 [email protected] Roll Skia from 4a2fddefd3d8 to cfae2af1bfeb (1 revision) (flutter/flutter#191642)
2026-08-25 [email protected] Roll Skia from 256c15026b91 to 4a2fddefd3d8 (6 revisions) (flutter/flutter#191633)
2026-08-25 [email protected] Remove octant_offset_c uniform from ubersdf, reorder/document ubersdf uniforms (flutter/flutter#191597)
2026-08-25 [email protected] Roll Fuchsia Linux SDK from 8Xu4ujBJniC0nQGx3... to MstTWE1RDOT-RnrtH... (flutter/flutter#191621)
2026-08-25 [email protected] Roll Dart SDK from 78bbc37b6ff6 to 2b75c83ddd77 (3 revisions) (flutter/flutter#191614)
2026-08-24 [email protected] [flutter_tools] Fix $git typo in shared.bat to restore cache invalidation on Windows (flutter/flutter#191217)
2026-08-24 [email protected] Skip removed observers during app exit requests (flutter/flutter#190343)
2026-08-24 [email protected] [engine] Support UTF-8 paths in Windows filesystem and path APIs (flutter/flutter#191360)
2026-08-24 [email protected] Migrate ios driver tests batch 3 to simulators (flutter/flutter#191333)
2026-08-24 [email protected] Migrate texture example to material_ui (flutter/flutter#190673)
2026-08-24 [email protected] Remove outdated test todo about `dither` property of `Paint` (flutter/flutter#190936)
2026-08-24 [email protected] Add agent rule to prevent using material and cupertino in widget tests (flutter/flutter#191588)
2026-08-24 [email protected] [flutter_tools] Prevent crash when stdout is broken and print fails (flutter/flutter#191356)
2026-08-24 [email protected] Add FlViewRendererSubsurface (flutter/flutter#191389)
2026-08-24 [email protected] [Android] Inject `route` into manifest when specified on the command line in release mode (flutter/flutter#191328)
2026-08-24 [email protected] [AGP 9.1.0 Migration #3] Add buildModeFor overloads and wire Flutter dependencies through the new DSL (flutter/flutter#191218)
2026-08-24 [email protected] Roll Skia from 698c60bf58f1 to 256c15026b91 (1 revision) (flutter/flutter#191586)
2026-08-24 [email protected] On iOS 27+ devices, manually process lldb stops (flutter/flutter#191434)
2026-08-24 [email protected] [flutter_tools] Handle missing Xcode gracefully in getInfo and buildMacOS (flutter/flutter#191180)
2026-08-24 [email protected] [flutter_tools] Handle null version gracefully in CachedArtifact and MaterialFonts (flutter/flutter#191494)
2026-08-24 [email protected] [flutter_tools] Do not treat 'daemon' argument as daemon command in logger initialization (flutter/flutter#191442)
2026-08-24 [email protected] [flutter_tools] Resolve workspace root when running widget preview from member package (flutter/flutter#190952)
2026-08-24 [email protected] [native_assets] Roll native packages (flutter/flutter#191253)
2026-08-24 [email protected] [flutter_tools] Add --force flag to flutter channel (flutter/flutter#191579)
2026-08-24 [email protected] Roll Skia from 57968d087d18 to 698c60bf58f1 (1 revision) (flutter/flutter#191577)

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 [email protected],[email protected] 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

...
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…r#12619)

Roll Flutter from 9a8278982588 to 15d8908addf6 (37 revisions)

flutter/flutter@9a82789...15d8908

2026-08-25 [email protected] Roll Packages from df2ba94 to 740f093 (17 revisions) (flutter/flutter#191734)
2026-08-25 [email protected] [record_use] Remove const_finder (flutter/flutter#191702)
2026-08-25 [email protected] Warn when SwiftPM is disabled (flutter/flutter#188695)
2026-08-25 [email protected] Roll Skia from b1a31575c373 to 480540178356 (1 revision) (flutter/flutter#191723)
2026-08-25 [email protected] Roll pub packages (flutter/flutter#191726)
2026-08-25 [email protected] Roll Skia from bfa276ed9ac5 to b1a31575c373 (1 revision) (flutter/flutter#191717)
2026-08-25 [email protected] Roll Dart SDK from 0818e6dc28cc to 8996935d3d0a (2 revisions) (flutter/flutter#191706)
2026-08-25 [email protected] Roll Skia from 31799e707cd4 to bfa276ed9ac5 (1 revision) (flutter/flutter#191701)
2026-08-25 [email protected] iOS: Add null check for touch rate correction task runner (flutter/flutter#191641)
2026-08-25 [email protected] iOS: Add test for engineAllowHeadlessExecution (flutter/flutter#191635)
2026-08-25 [email protected] Roll Skia from cfae2af1bfeb to 31799e707cd4 (4 revisions) (flutter/flutter#191649)
2026-08-25 [email protected] Roll Dart SDK from 2b75c83ddd77 to 0818e6dc28cc (1 revision) (flutter/flutter#191643)
2026-08-25 [email protected] Roll Skia from 4a2fddefd3d8 to cfae2af1bfeb (1 revision) (flutter/flutter#191642)
2026-08-25 [email protected] Roll Skia from 256c15026b91 to 4a2fddefd3d8 (6 revisions) (flutter/flutter#191633)
2026-08-25 [email protected] Remove octant_offset_c uniform from ubersdf, reorder/document ubersdf uniforms (flutter/flutter#191597)
2026-08-25 [email protected] Roll Fuchsia Linux SDK from 8Xu4ujBJniC0nQGx3... to MstTWE1RDOT-RnrtH... (flutter/flutter#191621)
2026-08-25 [email protected] Roll Dart SDK from 78bbc37b6ff6 to 2b75c83ddd77 (3 revisions) (flutter/flutter#191614)
2026-08-24 [email protected] [flutter_tools] Fix $git typo in shared.bat to restore cache invalidation on Windows (flutter/flutter#191217)
2026-08-24 [email protected] Skip removed observers during app exit requests (flutter/flutter#190343)
2026-08-24 [email protected] [engine] Support UTF-8 paths in Windows filesystem and path APIs (flutter/flutter#191360)
2026-08-24 [email protected] Migrate ios driver tests batch 3 to simulators (flutter/flutter#191333)
2026-08-24 [email protected] Migrate texture example to material_ui (flutter/flutter#190673)
2026-08-24 [email protected] Remove outdated test todo about `dither` property of `Paint` (flutter/flutter#190936)
2026-08-24 [email protected] Add agent rule to prevent using material and cupertino in widget tests (flutter/flutter#191588)
2026-08-24 [email protected] [flutter_tools] Prevent crash when stdout is broken and print fails (flutter/flutter#191356)
2026-08-24 [email protected] Add FlViewRendererSubsurface (flutter/flutter#191389)
2026-08-24 [email protected] [Android] Inject `route` into manifest when specified on the command line in release mode (flutter/flutter#191328)
2026-08-24 [email protected] [AGP 9.1.0 Migration flutter#3] Add buildModeFor overloads and wire Flutter dependencies through the new DSL (flutter/flutter#191218)
2026-08-24 [email protected] Roll Skia from 698c60bf58f1 to 256c15026b91 (1 revision) (flutter/flutter#191586)
2026-08-24 [email protected] On iOS 27+ devices, manually process lldb stops (flutter/flutter#191434)
2026-08-24 [email protected] [flutter_tools] Handle missing Xcode gracefully in getInfo and buildMacOS (flutter/flutter#191180)
2026-08-24 [email protected] [flutter_tools] Handle null version gracefully in CachedArtifact and MaterialFonts (flutter/flutter#191494)
2026-08-24 [email protected] [flutter_tools] Do not treat 'daemon' argument as daemon command in logger initialization (flutter/flutter#191442)
2026-08-24 [email protected] [flutter_tools] Resolve workspace root when running widget preview from member package (flutter/flutter#190952)
2026-08-24 [email protected] [native_assets] Roll native packages (flutter/flutter#191253)
2026-08-24 [email protected] [flutter_tools] Add --force flag to flutter channel (flutter/flutter#191579)
2026-08-24 [email protected] Roll Skia from 57968d087d18 to 698c60bf58f1 (1 revision) (flutter/flutter#191577)

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 [email protected],[email protected] 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

...
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…r#12619)

Roll Flutter from 9a8278982588 to 15d8908addf6 (37 revisions)

flutter/flutter@9a82789...15d8908

2026-08-25 [email protected] Roll Packages from df2ba94 to 740f093 (17 revisions) (flutter/flutter#191734)
2026-08-25 [email protected] [record_use] Remove const_finder (flutter/flutter#191702)
2026-08-25 [email protected] Warn when SwiftPM is disabled (flutter/flutter#188695)
2026-08-25 [email protected] Roll Skia from b1a31575c373 to 480540178356 (1 revision) (flutter/flutter#191723)
2026-08-25 [email protected] Roll pub packages (flutter/flutter#191726)
2026-08-25 [email protected] Roll Skia from bfa276ed9ac5 to b1a31575c373 (1 revision) (flutter/flutter#191717)
2026-08-25 [email protected] Roll Dart SDK from 0818e6dc28cc to 8996935d3d0a (2 revisions) (flutter/flutter#191706)
2026-08-25 [email protected] Roll Skia from 31799e707cd4 to bfa276ed9ac5 (1 revision) (flutter/flutter#191701)
2026-08-25 [email protected] iOS: Add null check for touch rate correction task runner (flutter/flutter#191641)
2026-08-25 [email protected] iOS: Add test for engineAllowHeadlessExecution (flutter/flutter#191635)
2026-08-25 [email protected] Roll Skia from cfae2af1bfeb to 31799e707cd4 (4 revisions) (flutter/flutter#191649)
2026-08-25 [email protected] Roll Dart SDK from 2b75c83ddd77 to 0818e6dc28cc (1 revision) (flutter/flutter#191643)
2026-08-25 [email protected] Roll Skia from 4a2fddefd3d8 to cfae2af1bfeb (1 revision) (flutter/flutter#191642)
2026-08-25 [email protected] Roll Skia from 256c15026b91 to 4a2fddefd3d8 (6 revisions) (flutter/flutter#191633)
2026-08-25 [email protected] Remove octant_offset_c uniform from ubersdf, reorder/document ubersdf uniforms (flutter/flutter#191597)
2026-08-25 [email protected] Roll Fuchsia Linux SDK from 8Xu4ujBJniC0nQGx3... to MstTWE1RDOT-RnrtH... (flutter/flutter#191621)
2026-08-25 [email protected] Roll Dart SDK from 78bbc37b6ff6 to 2b75c83ddd77 (3 revisions) (flutter/flutter#191614)
2026-08-24 [email protected] [flutter_tools] Fix $git typo in shared.bat to restore cache invalidation on Windows (flutter/flutter#191217)
2026-08-24 [email protected] Skip removed observers during app exit requests (flutter/flutter#190343)
2026-08-24 [email protected] [engine] Support UTF-8 paths in Windows filesystem and path APIs (flutter/flutter#191360)
2026-08-24 [email protected] Migrate ios driver tests batch 3 to simulators (flutter/flutter#191333)
2026-08-24 [email protected] Migrate texture example to material_ui (flutter/flutter#190673)
2026-08-24 [email protected] Remove outdated test todo about `dither` property of `Paint` (flutter/flutter#190936)
2026-08-24 [email protected] Add agent rule to prevent using material and cupertino in widget tests (flutter/flutter#191588)
2026-08-24 [email protected] [flutter_tools] Prevent crash when stdout is broken and print fails (flutter/flutter#191356)
2026-08-24 [email protected] Add FlViewRendererSubsurface (flutter/flutter#191389)
2026-08-24 [email protected] [Android] Inject `route` into manifest when specified on the command line in release mode (flutter/flutter#191328)
2026-08-24 [email protected] [AGP 9.1.0 Migration flutter#3] Add buildModeFor overloads and wire Flutter dependencies through the new DSL (flutter/flutter#191218)
2026-08-24 [email protected] Roll Skia from 698c60bf58f1 to 256c15026b91 (1 revision) (flutter/flutter#191586)
2026-08-24 [email protected] On iOS 27+ devices, manually process lldb stops (flutter/flutter#191434)
2026-08-24 [email protected] [flutter_tools] Handle missing Xcode gracefully in getInfo and buildMacOS (flutter/flutter#191180)
2026-08-24 [email protected] [flutter_tools] Handle null version gracefully in CachedArtifact and MaterialFonts (flutter/flutter#191494)
2026-08-24 [email protected] [flutter_tools] Do not treat 'daemon' argument as daemon command in logger initialization (flutter/flutter#191442)
2026-08-24 [email protected] [flutter_tools] Resolve workspace root when running widget preview from member package (flutter/flutter#190952)
2026-08-24 [email protected] [native_assets] Roll native packages (flutter/flutter#191253)
2026-08-24 [email protected] [flutter_tools] Add --force flag to flutter channel (flutter/flutter#191579)
2026-08-24 [email protected] Roll Skia from 57968d087d18 to 698c60bf58f1 (1 revision) (flutter/flutter#191577)

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 [email protected],[email protected] 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

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

_CastError: Null check operator used on a null value at MaterialFonts.updateInner(flutter_cache.dart:141)

2 participants