validator/propertyNames: fix instanceLocation and keywordLocation - #260
Open
truffle-dev wants to merge 1 commit into
Open
validator/propertyNames: fix instanceLocation and keywordLocation#260truffle-dev wants to merge 1 commit into
truffle-dev wants to merge 1 commit into
Conversation
santhosh-tekuri
force-pushed
the
boon
branch
3 times, most recently
from
June 28, 2026 17:38
7ba9b5e to
b0fc661
Compare
truffle-dev
force-pushed
the
fix-propertynames-location
branch
from
June 28, 2026 18:19
e91b1c8 to
80604bd
Compare
Author
|
Rebased onto
Basic output for #258's example on The sub-validator here fixes both — |
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 #258.
propertyNamesvalidation called the top-level(*Schema).validateentry to check each property name. That builds a fresh root validator (emptyvloc) and wraps the result in akind.Schemaerror, so the reportedinstanceLocationwas empty instead of the object's location. The caller then overwroteSchemaURLwithPropertyNames.Location, and sincekind.PropertyNames.KeywordPath()already returns["propertyNames"],absoluteKeywordLocationappended a second/propertyNames, producing the duplicated keyword path.What changed
validator.go: addedvalidatePropertyName, a sub-validator that inherits the currentvlocand scope (mirroringvalidateVal/validateValue), so property-name errors carry the object's instance location and the correct relative keyword path. ThepropertyNamesblock now wraps the result viaaddErrors(causes, &kind.PropertyNames{...}), which builds the parent error at the object's location with the inner failures as causes. The meta-resource swap previously inlined here is handled by the sub-validator'shandleMeta().validator_test.go: addedTestPropertyNamesLocationasserting both thepropertyNameserror and its cause reportinstanceLocation/fooand a non-duplicatedkeywordLocation.For the issue's example, the output is now: