fix(config): address jsonschema/v6 Go Fan review — Draft hint, errors.New, UnmarshalJSON precision - #9403
Conversation
…use UnmarshalJSON for precision
There was a problem hiding this comment.
Pull request overview
Updates JSON Schema validation messaging and error construction while attempting precision-safe custom-schema parsing.
Changes:
- Corrects the supported JSON Schema draft hint.
- Uses
errors.Newfor static error construction. - Switches server validation parsing to
jsonschema.UnmarshalJSON.
Show a summary per file
| File | Description |
|---|---|
internal/config/validation_server.go |
Updates schema guidance and parsing behavior. |
internal/config/validation_schema.go |
Simplifies formatted error construction. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Medium
| // Parse using jsonschema.UnmarshalJSON for number-precision consistency with embedded schema path | ||
| serverObj, parseErr := jsonschema.UnmarshalJSON(bytes.NewReader(serverJSON)) |
|
@copilot address review feedback |
Fixed in the latest commit. The root cause was in Change: replaced the Regression test added in |
Three quick-win improvements surfaced by the Go Fan module review of
santhosh-tekuri/jsonschema/v6.Changes
Fix misleading Draft 7 error hint (
validation_server.go): The compile-failure hint incorrectly said "Draft 7" when the compiler defaults to Draft 2020-12. Updated to"valid JSON Schema document (Draft 2020-12 or earlier)".Replace
fmt.Errorf("%s", ...)witherrors.New(validation_schema.go): No format verbs, no wrapping —errors.New(sb.String())is the correct idiom.Use
jsonschema.UnmarshalJSONinvalidateServerAgainstSchema(validation_server.go): Aligns the custom-schema validation path with the embedded-schema path, avoiding potential number-precision loss fromencoding/json.Unmarshalon large integers or high-precision floats.serverMapis initialized before the type assertion to guarantee it is never nil.The test for the unknown
ErrorKinddefault path inTestFormatErrorContextalready existed (kind.Not{}case), so no new test was needed.