-
Notifications
You must be signed in to change notification settings - Fork 90
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
Error message is misleading when defining an attribute incorrectly in schema JSON #417
Comments
That's a subtle bug. It's an unintended consequence of the behavior noted here and how it interacts with some artifact of how serde handles its internal state. What's happening is that
|
Another example of this class of error came up recently. The only difference is that the error on the top level attribute instead of a nested attribute. {
"": {
"entityTypes": {
"User": {
"shape": {
"type": "Record",
"attributes": {
"foo": {
"type": "Record",
"element": { "type": "Long" }
},
"bar": { "type": "Long" }
}
}
}
},
"actions": {}
}
} error is
FWIW, this issue should be easy to fix if we don't mind having slight less helpful error messages when a JSON schema contains parse errors inside unexpected fields. It would complain about the error in the field before complaining about the existence of the field. This error as it stands is bad enough that IMO it's easily worth it. |
Signed-off-by: John Kastner <jkastner@amazon.com>
Signed-off-by: John Kastner <jkastner@amazon.com>
Before opening, please confirm:
Bug Category
Schemas and Validation
Describe the bug
For the below schema, the reported error is
This is misleading because
baz
is a completely valid field (attribute name), and changingbaz
to some other string (like the ones listed) will not fix the problem.Instead, the issue is in the
bar
field. The set element type was listed as"Long"
instead of{ "type": "Long" }
.If you fix the set-element mistake, you see that a similar mistake was made in the
baz
field, but that one actually has a reasonable-ish error message once you fix the set-element mistake:This actually points to the correct problem location (
"Boolean"
), and from this error message an end-user could probably decipher a hint that they need a JSON object instead of just the string"Boolean"
. (This error message itself could definitely be improved, too; for instance, we could suggest that you need{ "type": ... }
instead of using the cryptic termTypeOfAttribute
; and we could even perhaps suggest{ "type": "Boolean" }
in this particular case.)Expected behavior
A better error message -- at least one that points to the
bar
attribute instead ofbaz
, and ideally a reasonable suggested fix. See above.Reproduction steps
Try to parse the schema given below
Code Snippet
Log output
No response
Additional configuration
No response
Operating System
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: