Skip to content

Commit

Permalink
[parser] throw exception on bad default value in union (#347)
Browse files Browse the repository at this point in the history
* [parser] throw exception on bad default

* exception -> context.addIssue

Co-authored-by: David Grossman <dgrosman@linkedin.com>
  • Loading branch information
dg-builder and David Grossman authored Jun 16, 2022
1 parent ba4ec6b commit 4154243
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,12 @@ private AvroNamedSchema parseNamedSchema(
//(legal) default values are expected to match the 1st union branch
defaultValueExpectedSchema = ((AvroUnionSchema) defaultValueExpectedSchema).getTypes().get(0).getSchema();
}
LiteralOrIssue defaultValurOrIssue = parseLiteral(fieldDefaultValueNode, defaultValueExpectedSchema, fieldName.getValue(), context);
if (defaultValurOrIssue.getIssue() == null) {
LiteralOrIssue defaultValueOrIssue = parseLiteral(fieldDefaultValueNode, defaultValueExpectedSchema, fieldName.getValue(), context);
if (defaultValueOrIssue.getIssue() == null) {
//TODO - allow parsing default values that are branch != 0 (and add an issue)
defaultValue = defaultValurOrIssue.getLiteral();
defaultValue = defaultValueOrIssue.getLiteral();
} else {
context.addIssue(defaultValueOrIssue.getIssue());
}
//TODO - handle issues
} else {
Expand Down

0 comments on commit 4154243

Please sign in to comment.