atlassian / atlassian/better-ajv-errors
Stack trace while validating bad file. Could use help with schema and oneOf errors.
- Dominant language
- JavaScript
- Stars
- 245
- Forks
- 50
- PR merge metrics
- No merged PRs in 30d
Description
better ajv:
```
$ node.exe index.betterajverrors.js examples.bad/HelloWorldProgramOutput.json
Loading schema
Parsing schema
Adding schema
Schema 4.1 added
Schema 4.1 compiled
================================================================================
File: examples.bad/HelloWorldProgramOutput.json
================================================================================
File: examples.bad/HelloWorldProgramOutput.json
Error: Couldn't find property -children of /X3D/Scene/-children/1/NavigationInfo
at file:///C:/Users/jcarl/x3dvalidate/node_modules/better-ajv-errors/lib/esm/json/get-meta-from-path.mjs:13:17
at Array.reduce ()
at getMetaFromPath (file:///C:/Users/jcarl/x3dvalidate/node_modules/better-ajv-errors/lib/esm/json/get-meta-from-path.mjs:6:19)
at RequiredValidationError.getLocation (file:///C:/Users/jcarl/x3dvalidate/node_modules/better-ajv-errors/lib/esm/validation-errors/base.mjs:14:21)
at RequiredValidationError.getLocation (file:///C:/Users/jcarl/x3dvalidate/node_modules/better-ajv-errors/lib/esm/validation-errors/required.mjs:6:29)
at RequiredValidationError.getError (file:///C:/Users/jcarl/x3dvalidate/node_modules/better-ajv-errors/lib/esm/validation-errors/required.mjs:21:15)
at customErrorToStructure (file:///C:/Users/jcarl/x3dvalidate/node_modules/better-ajv-errors/lib/esm/index.mjs:9:51)
at Array.map ()
at index_default (file:///C:/Users/jcarl/x3dvalidate/node_modules/better-ajv-errors/lib/esm/index.mjs:19:25)
at doValidate (file:///C:/Users/jcarl/x3dvalidate/index.betterajverrors.js:48:19)
```
Normal ajv:
```
$ node.exe index.js --fullreport examples.bad/HelloWorldProgramOutput.json
Toggling suppression in in files now.
Loading schema
Parsing schema
Adding schema
Schema 4.1 added
Schema 4.1 compiled
================================================================================
File: examples.bad/HelloWorldProgramOutput.json
Error invalid file examples.bad/HelloWorldProgramOutput.json
keyword: required
location in document: /X3D/Scene/-children/1/NavigationInfo
message: must have required property '@USE'
params: {"missingProperty":"@USE"}
file: examples.bad/HelloWorldProgramOutput.json
version: 4.1
keyword: type
location in document: /X3D/Scene/-children/1/NavigationInfo/@type
message: must be array
params: {"type":"array"}
file: examples.bad/HelloWorldProgramOutput.json
version: 4.1
keyword: oneOf
location in document: /X3D/Scene/-children/1/NavigationInfo
message: must match exactly one schema in oneOf
params: {"passingSchemas":null}
file: examples.bad/HelloWorldProgramOutput.json
version: 4.1
```
I am also including schema and AllAudioGraphNodesTest.json and a normal ajv error reporter which seems to close down on the error in the file better than better-ajv-errors.
```
$ node.exe index.betterajverrors.js examples.bad/AllAudioGraphNodesTest.json
Loading schema
Parsing schema
Adding schema
Schema 4.1 added
Schema 4.1 compiled
================================================================================
File: examples.bad/AllAudioGraphNodesTest.json
Error invalid file examples.bad/AllAudioGraphNodesTest.json [
{
start: { line: 67, column: 13, offset: 2161 },
error: "/X3D/Scene/-children/1/Shape must have required property '@USE'",
path: '/X3D/Scene/-children/1/Shape'
}
]
```
Filtered ajv:
```
$ node.exe index.js examples.bad/AllAudioGraphNodesTest.json
Loading schema
Parsing schema
Adding schema
Schema 4.1 added
Schema 4.1 compiled
================================================================================
File: examples.bad/AllAudioGraphNodesTest.json
Suppressing @USE missing property. Use --fullreport to reveal possibly confusing errors
Suppressing @USE missing property. Use --fullreport to reveal possibly confusing errors
Suppressing null passingSchemas. Use --fullreport to reveal possibly confusing errors
Suppressing null passingSchemas. Use --fullreport to reveal possibly confusing errors
Error invalid file examples.bad/AllAudioGraphNodesTest.json
keyword: type
location in document: /X3D/Scene/-children/1/Shape/-appearance/Appearance/-acousticProperties
message: must be object
params: {"type":"object"}
file: examples.bad/AllAudioGraphNodesTest.json
version: 4.1
````
Normal ajv:
```
$ node.exe index.js --fullreport examples.bad/AllAudioGraphNodesTest.json
Toggling suppression in in files now.
Loading schema
Parsing schema
Adding schema
Schema 4.1 added
Schema 4.1 compiled
================================================================================
File: examples.bad/AllAudioGraphNodesTest.json
Error invalid file examples.bad/AllAudioGraphNodesTest.json
keyword: required
location in document: /X3D/Scene/-children/1/Shape
message: must have required property '@USE'
params: {"missingProperty":"@USE"}
file: examples.bad/AllAudioGraphNodesTest.json
version: 4.1
keyword: required
location in document: /X3D/Scene/-children/1/Shape/-appearance/Appearance
message: must have required property '@USE'
params: {"missingProperty":"@USE"}
file: examples.bad/AllAudioGraphNodesTest.json
version: 4.1
keyword: type
location in document: /X3D/Scene/-children/1/Shape/-appearance/Appearance/-acousticProperties
message: must be object
params: {"type":"object"}
file: examples.bad/AllAudioGraphNodesTest.json
version: 4.1
keyword: oneOf
location in document: /X3D/Scene/-children/1/Shape/-appearance/Appearance
message: must match exactly one schema in oneOf
params: {"passingSchemas":null}
file: examples.bad/AllAudioGraphNodesTest.json
version: 4.1
keyword: oneOf
location in document: /X3D/Scene/-children/1/Shape
message: must match exactly one schema in oneOf
params: {"passingSchemas":null}
file: examples.bad/AllAudioGraphNodesTest.json
version: 4.1
```
If you can catch my error in the schema why there's so many errors, great. Apparently, I can't use strict mode currently.
[StackTraceErrorZip.zip](https://github.com/user-attachments/files/27000978/StackTraceErrorZip.zip)
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the reports with index.betterajverrors.js using examples.bad/HelloWorldProgramOutput.json and examples.bad/AllAudioGraphNodesTest.json, then inspect lib/esm/json/get-meta-from-path.mjs and the validation-errors files named in the stack trace. Compare the output with index.js in full-report mode; done means invalid paths no longer cause a stack trace and required and oneOf errors are reported consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100