json-schema-sandbox $ node ./test-draft-2020-12.js
file:///Volumes/Projects/github.com/hyperjump-io/json-schema/node_modules/@hyperjump/json-pointer/lib/index.js:149
throw TypeError(`Value at '${cursor}' is undefined and does not have property '${segment}'`);
^
TypeError: Value at '/paths/~1pets~1%7Bid%7D' is undefined and does not have property 'get'
at applySegment (file:///Volumes/Projects/github.com/hyperjump-io/json-schema/node_modules/@hyperjump/json-pointer/lib/index.js:149:11)
at _get (file:///Volumes/Projects/github.com/hyperjump-io/json-schema/node_modules/@hyperjump/json-pointer/lib/index.js:45:30)
at _get (file:///Volumes/Projects/github.com/hyperjump-io/json-schema/node_modules/@hyperjump/json-pointer/lib/index.js:45:12)
at _get (file:///Volumes/Projects/github.com/hyperjump-io/json-schema/node_modules/@hyperjump/json-pointer/lib/index.js:45:12)
at fn (file:///Volumes/Projects/github.com/hyperjump-io/json-schema/node_modules/@hyperjump/json-pointer/lib/index.js:36:27)
at get (file:///Volumes/Projects/github.com/hyperjump-io/json-schema/node_modules/@hyperjump/json-pointer/lib/index.js:37:39)
at Module.get (file:///Volumes/Projects/github.com/hyperjump-io/json-schema/lib/instance.js:24:12)
at Object.<anonymous> (file:///Volumes/Projects/github.com/hyperjump-io/json-schema/annotations/index.js:41:28)
at publish (file:///Volumes/Projects/github.com/hyperjump-io/json-schema/lib/pubsub.js:23:57)
at Object.interpret (file:///Volumes/Projects/github.com/hyperjump-io/json-schema/lib/keywords/validation.js:66:13)
Node.js v18.17.1
The reason is that the JSON pointers for the instance location of an annotation are not properly URI-decoded. Consider the the above schema will produce this annotations value:
But this is wrong — because this annotations object is not keyed by a relative pointer URI, but rather by the fragment value from a relative pointer URI, it should be:
The following code produces an error:
The reason is that the JSON pointers for the instance location of an annotation are not properly URI-decoded. Consider the the above schema will produce this
annotations
value:But this is wrong — because this annotations object is not keyed by a relative pointer URI, but rather by the fragment value from a relative pointer URI, it should be:
This mismatched logic produces the error, but the annotations are actually themselves wrong.