You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add line/column positions to JSON and YAML schema errors
Schema validation errors now include source positions, pointing to the
exact line and column of the offending key in the original file.
For JSON, a position map is built by tokenizing the source with
encoding/json.Decoder and tracking byte offsets for each key path.
For YAML, the yaml.v3 Node API provides line/column on every node.
The gojsonschema library reports errors with JSON paths like
"(root).server.port". These paths are looked up in the position map
to annotate each error with its source location.
Changes:
- SchemaErrors gains a Positions field (parallel to Items)
- New SourcePosition type and JSONSchemaValidateWithPositions function
- buildJSONPositionMap: tokenizes JSON and maps context paths to positions
- buildYAMLPositionMap/walkYAMLNode: walks yaml.v3 Node tree for positions
- Report gains ErrorLines/ErrorColumns (parallel to ValidationErrors)
- SARIF reporter uses per-error positions instead of file-level position
- formatErrors formats schema errors with consistent line/column prefix
Output before:
error: schema: version: Invalid type. Expected: string, given: integer
Output after:
error: schema: line 3, column 3: version: Invalid type. Expected: string, given: integer
0 commit comments