-
-
Notifications
You must be signed in to change notification settings - Fork 581
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
additionalItems can blow up when rendering a message for a non-homogeneous array #1157
Comments
Hi. Thanks. Can you include a full reproducing example? |
Unfortunately this was part of a larger job that failed and I didn't catch the specific input. I do however have a stack trace.
|
I have the same issue. Here's a minimal schema for reproduction: {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"type": "object",
"properties": {
"array_multiple_types": {
"oneOf": [
{
"type": "array",
"items": [
{
"const": "test1"
}
],
"additionalItems": false,
"minItems": 1
},
{
"type": "array",
"items": [
{
"const": "test2"
},
{
"type": "string"
},
{
"type": "number"
}
],
"additionalItems": false,
"minItems": 3
}
]
}
}
} and an instance to be validated: {
"array_multiple_types": [
"test2",
"aaa",
99
]
} Although the proposed solution does fix the problem, my first instinct would be to not sort a list if I'm not sure it's homogenous. Sorting also makes the error message slightly more confusing as it shows elements in a different ordering from the validated instance. I would just remove it. return ", ".join(repr(extra) for extra in extras), verb Thanks for the project BTW! |
Thanks, that helps! |
We actually don't have any of these! Ref: python-jsonschema/jsonschema#1157
The
extras_msg
function sometimes throws an exception when everything in extras is not the same type because sorting fails.Assuming the specific sort order is not terribly important, changing from
to
should solve the problem.
The text was updated successfully, but these errors were encountered: