Skip to content

Handle wrapped jsonschema validation errors in config schema formatting#7385

Merged
lpcox merged 2 commits into
mainfrom
copilot/go-fan-review-jsonschema
Jun 11, 2026
Merged

Handle wrapped jsonschema validation errors in config schema formatting#7385
lpcox merged 2 commits into
mainfrom
copilot/go-fan-review-jsonschema

Conversation

Copilot AI commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

formatSchemaError only recognized direct *jsonschema.ValidationError values, so wrapped schema errors were downgraded to the generic error path and lost location/cause diagnostics. This change makes schema error formatting resilient to wrapping while preserving existing output behavior for direct and non-schema errors.

  • Schema error unwrapping

    • Switched formatSchemaError from direct type assertion to errors.As when detecting *jsonschema.ValidationError.
    • Preserves rich formatting (instance location, recursive causes, docs footer) even when validation errors are wrapped.
  • Targeted regression coverage

    • Added a focused test case for a wrapped jsonschema.ValidationError to ensure the detailed formatting branch is used.
var ve *jsonschema.ValidationError
if errors.As(err, &ve) {
    formatValidationErrorRecursive(ve, &sb, 0)
    rules.AppendConfigDocsFooter(&sb)
}

GitHub Advanced Security started work on behalf of lpcox June 11, 2026 18:03 View session
GitHub Advanced Security finished work on behalf of lpcox June 11, 2026 18:05
GitHub Advanced Security started work on behalf of lpcox June 11, 2026 18:10 View session
GitHub Advanced Security finished work on behalf of lpcox June 11, 2026 18:12
Copilot AI changed the title [WIP] Update santhosh-tekuri/jsonschema to version v6.0.2 Handle wrapped jsonschema validation errors in config schema formatting Jun 11, 2026
Copilot finished work on behalf of lpcox June 11, 2026 18:13
Copilot AI requested a review from lpcox June 11, 2026 18:13
@lpcox lpcox marked this pull request as ready for review June 11, 2026 18:20
Copilot AI review requested due to automatic review settings June 11, 2026 18:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves config JSON Schema validation error formatting by ensuring wrapped *jsonschema.ValidationError instances still receive the detailed, location-aware formatting (including recursive causes and the docs footer), instead of falling back to the generic error string path.

Changes:

  • Updated formatSchemaError to detect *jsonschema.ValidationError via errors.As (handles wrapped errors).
  • Added a regression test covering a wrapped jsonschema.ValidationError to ensure detailed formatting is preserved.
Show a summary per file
File Description
internal/config/validation_schema.go Switches schema error detection to errors.As so wrapped validation errors keep rich formatting output.
internal/config/validation_schema_error_format_test.go Adds a targeted test that wraps a ValidationError and asserts the detailed formatting branch is used.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@lpcox lpcox merged commit cec6c7d into main Jun 11, 2026
46 checks passed
@lpcox lpcox deleted the copilot/go-fan-review-jsonschema branch June 11, 2026 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants