Repository navigation
fix: report propertyNames errors on the offending key - #153
Open
tarunagnihotri534 wants to merge 1 commit into
Open
tarunagnihotri534 wants to merge 1 commit into
tarunagnihotri534 wants to merge 1 commit into
Conversation
1 task done
jdesrosiers
requested changes
Oct 14, 2026
jdesrosiers
left a comment
Collaborator
There was a problem hiding this comment.
This is the wrong approach. Update JsonDocument.findNodeAtPointer to understand the * syntax. Then it will work everywhere, not just for schema validation diagnostics.
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 #151
What this fixes
When a schema used
propertyNamesand a document had a key that failed it, the real validation error was never reported on that key. Instead, the server showed "Invalid JSON Pointer" on the document's$schemaline.Root cause
In
SchemaValidationDiagnosticsProvider.ts:propertyNamesviolations,@hyperjump/json-schemareportsinstanceLocationas#*<pointer>(for example#*/123or#*/nested/123).#left*/123, which was passed tojsonDocument.findNodeAtPointer. Since it doesn't start with/,@hyperjump/json-pointerthrewInvalid JSON Pointer.catchattached that message to/$schema, and the real diagnostic was never created.Changes
toPointerhelper instead ofdecodeURIComponent(error.instanceLocation.slice(1)). It already strips the leading*.instanceLocationstarts with#*and the resolved node belongs to a property, the diagnostic is attached to the property's key node (node.parent.children[0]).catchfallback is unchanged.Tests
Added to
SchemaValidationDiagnosticsProvider.test.ts:propertyNamesgets a diagnostic on that key, and none on$schema/and~) are placed correctlyI confirmed the first test failed before the fix, with "Invalid JSON Pointer" reported on
$schema.Testing
vitest run: 20 files, 465 tests passtsc --noEmit: no errorsoxlint src: 0 warnings, 0 errorsNotes
main, so the two shouldn't conflict.