-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Handle null values during yaml metadata parsing validation #104022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| expect(logger.traceText, contains('.metadata file at .metadata was empty or malformed.')); | ||
| }); | ||
|
|
||
| testWithoutContext('projectType is populated when version is null', () { |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
christopherfujino
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
And other casting fixups.
Fixes #104021
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.