Skip to content

[tool_crash] StateError (Bad state: No element) in testCompilerBuildNativeAssets #192933

Closed

Description

@bkonyi

Description

In Flutter 3.47.3 crash telemetry, testCompilerBuildNativeAssets threw an unhandled StateError: Bad state: No element (36 crashes in the first 7 days post-release).

Stack Trace

Iterable.firstWhere at dart:core/iterable.dart:722
testCompilerBuildNativeAssets at package:flutter_tools/src/isolated/native_assets/test/native_assets.dart:37
TestCompilerNativeAssetsBuilderImpl.build at package:flutter_tools/src/isolated/native_assets/test/native_assets.dart:22
TestCommand.runCommand at package:flutter_tools/src/commands/test.dart:504

Cause

In package:flutter_tools/src/isolated/native_assets/test/native_assets.dart:

final Uri projectUri = FlutterProject.current().directory.uri;
final String runPackageName = buildInfo.packageConfig.packages
    .firstWhere((Package p) => p.root == projectUri)
    .name;

firstWhere throws StateError when no package in buildInfo.packageConfig.packages has its root matching projectUri (for example, in pub workspaces, symlinked directories, or when invoking flutter test from a sub-directory).

Proposed Fix

Use firstWhereOrNull or check against root URIs and fall back gracefully to the target project/package name from pubspec rather than crashing.

Activity

  1. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    team-toolOwned by Flutter Tool team
    P1High-priority issues at the top of the work list
    triaged-toolTriaged by Flutter Tool team
    on Sep 17, 2026
  2. self-assigned this
    on Sep 17, 2026
  3. github-actions commented on Nov 3, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  4. locked as resolved and limited conversation to collaborators on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listfound in release: 3.47Found to occur in 3.47t: top-crasherteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions