Skip to content

inaccurate error text shown when a non-null non-list is provided for assets section for a deferred component in pubspec #136163

@andrewkolos

Description

@andrewkolos

Consider this pubspec manifest:

name: test
dependencies:
  flutter:
    sdk: flutter
flutter:
  deferred-components:
    - name: blah
      assets: blah

Notice that, under the first and only deferred component, assets has a string value rather than a list.
In this case, the tool will print an error: Expected "assets" key in the 0 element of "deferred-components" to be a list, but got blah (String). However, the value is not a list, so the error is inaccurate.

Interestingly, providing assets: blah directly under flutter results in more accurate error text: Expected "assets" to be a list, but got blah (String).\n This is a result of us using completely separate parsing and validation code for parsing the top-level assets section and the assets sections under any deferred components.

testWithoutContext('FlutterManifest deferred component assets is list', () async {
const String manifest = '''
name: test
dependencies:
flutter:
sdk: flutter
flutter:
deferred-components:
- name: blah
assets: blah
''';
final BufferLogger logger = BufferLogger.test();
final FlutterManifest? flutterManifest = FlutterManifest.createFromString(
manifest,
logger: logger,
);
expect(flutterManifest, null);
expect(logger.errorText, 'Expected "assets" key in the 0 element of "deferred-components" to be a list, but got blah (String).\n');
});

Metadata

Metadata

Assignees

Labels

P3Issues that are less important to the Flutter projectteam-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