validator/additionalItems: fix instanceLocation#253
Merged
santhosh-tekuri merged 1 commit intosanthosh-tekuri:boonfrom Feb 18, 2026
Merged
validator/additionalItems: fix instanceLocation#253santhosh-tekuri merged 1 commit intosanthosh-tekuri:boonfrom
santhosh-tekuri merged 1 commit intosanthosh-tekuri:boonfrom
Conversation
additionalitems_test.go
Outdated
Owner
There was a problem hiding this comment.
can you add test case on file based error messages. see invalid_schemas_test.go
this makes it easier to add similar tests easier to just adding to json file without any code change.
Contributor
Author
There was a problem hiding this comment.
Moved to a json-driven approach following invalid_schemas_test.go. Created a separate testdata/validation_errors.json + runner since this tests validation errors rather than compile errors. Is
that what you had in mind, or would you prefer the test case added to invalid_schemas.json directly?
b1ff443 to
10b4874
Compare
Owner
|
I added error check support to existing test suite in 8d3372a
[
{
"description": "check index in error",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"items": [
{ "type": "string" },
{ "type": "string" }
],
"additionalItems": {
"type": "boolean"
}
},
"tests": [
{
"description": "with fraction",
"data": [ "a", "b", "c" ],
"valid": false,
"errors": [
"at '/2' [S#/additionalItems/type]: got string, want boolean"
]
}
]
}
] |
10b4874 to
6dfd9cb
Compare
6dfd9cb to
6101ad2
Compare
Contributor
Author
|
@santhosh-tekuri updated PR as per your review feedback |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #252.
The
additionalItemsvalidation loop iterates overarr[evaluated:]which re-indexes from 0, but uses the loop indexidirectly instrconv.Itoa(i)for the instance location. This reports/0instead of/2(or whatever the correct offset is) in validation errors.What changed
validator.go: changedstrconv.Itoa(i)tostrconv.Itoa(evaluated+i)on line 378additionalitems_test.go: addedTestAdditionalItemsErrorLocationusing draft-04 schema to verify the error points to the correct array index