diff --git a/packages/flutter_tools/lib/src/commands/assemble.dart b/packages/flutter_tools/lib/src/commands/assemble.dart index 6f8c1246cd..c591ed3513 100644 --- a/packages/flutter_tools/lib/src/commands/assemble.dart +++ b/packages/flutter_tools/lib/src/commands/assemble.dart @@ -291,7 +291,15 @@ class AssembleCommand extends FlutterCommand { } } Target target; - final List decodedDefines = decodeDartDefines(environment.defines, kDartDefines); + List decodedDefines; + try { + decodedDefines = decodeDartDefines(environment.defines, kDartDefines); + } on FormatException { + throwToolExit( + 'Error parsing assemble command: your generated configuration may be out of date. ' + "Try re-running 'flutter build ios' or the appropriate build command." + ); + } if (FlutterProject.current().manifest.deferredComponents != null && decodedDefines.contains('validate-deferred-components=true') && deferredTargets.isNotEmpty diff --git a/packages/flutter_tools/test/commands.shard/hermetic/assemble_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/assemble_test.dart index e900bf6879..746c6d685f 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/assemble_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/assemble_test.dart @@ -99,6 +99,28 @@ void main() { ProcessManager: () => FakeProcessManager.any(), }); + testUsingContext('flutter assemble throws ToolExit if dart-defines are not base64 encoded', () async { + final CommandRunner commandRunner = createTestCommandRunner(AssembleCommand( + buildSystem: TestBuildSystem.all(BuildResult(success: true)), + )); + + final List command = [ + 'assemble', + '--output', + 'Output', + '--DartDefines=flutter.inspector.structuredErrors%3Dtrue', + 'debug_macos_bundle_flutter_assets', + ]; + expect( + commandRunner.run(command), + throwsToolExit(message: 'Error parsing assemble command: your generated configuration may be out of date') + ); + }, overrides: { + Cache: () => Cache.test(processManager: FakeProcessManager.any()), + FileSystem: () => MemoryFileSystem.test(), + ProcessManager: () => FakeProcessManager.any(), + }); + testUsingContext('flutter assemble throws ToolExit if called with non-existent rule', () async { final CommandRunner commandRunner = createTestCommandRunner(AssembleCommand( buildSystem: TestBuildSystem.all(BuildResult(success: true)),