Skip to content

Conversation

@jmagman
Copy link
Member

@jmagman jmagman commented May 17, 2022

And other casting fixups.

Fixes #104021

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@jmagman jmagman self-assigned this May 17, 2022
@flutter-dashboard flutter-dashboard bot added the tool Affects the "flutter" command-line tool. See also t: labels. label May 17, 2022
@jmagman jmagman marked this pull request as ready for review May 17, 2022 23:11
expect(logger.traceText, contains('.metadata file at .metadata was empty or malformed.'));
});

testWithoutContext('projectType is populated when version is null', () {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test crashes with _CastError: Null check operator used on a null value on master.

break;
}
if (map[entry.key] != null && (map[entry.key] as Object).runtimeType != entry.value) {
final Object? metadataValue = map[entry.key];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the bug: when map[entry.key] was null, this method was returning true (valid).
Instead, check the map[entry.key] runtimeType even when it is null so it is marked as invalid and prints The value of key "x" in .metadata was expected to be y but was Null

// Handled in _validate below.
}
if (yamlRoot == null || yamlRoot is! YamlMap) {
if (yamlRoot is! YamlMap) {
Copy link
Member Author

@jmagman jmagman May 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yamlRoot is! YamlMap will be true for null, no need to check both.

@jmagman jmagman changed the title Fix up casting in yaml metadata parsing Handle null values during yaml metadata parsing validation May 17, 2022
Copy link
Contributor

@christopherfujino christopherfujino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fluttergithubbot fluttergithubbot merged commit 52ddc9d into flutter:master May 18, 2022
@jmagman jmagman deleted the type-cleanup branch May 18, 2022 01:39
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 18, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 18, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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 _validateMetadataMap

3 participants