[go-fan] Go Module Review: gojsonschema #6400
Closed
Replies: 2 comments 1 reply
-
|
/plan |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
⚓ Avast! This discussion be marked as outdated by Go Fan. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
🐹 Go Fan Report: github.com/xeipuuv/gojsonschema
The gojsonschema module is currently used for JSON Schema validation of campaign specifications in gh-aw. After deep analysis, I've discovered a critical finding: this library is unmaintained AND we're already using a better alternative elsewhere in the codebase!
🚨 Critical Finding: Library Duplication
gh-aw currently uses TWO different JSON Schema libraries:
github.com/xeipuuv/gojsonschema(draft-07, unmaintained) - Used in 1 filegithub.com/santhosh-tekuri/jsonschema/v6(draft 2020-12, actively maintained) - Used in 5 filesThis creates unnecessary complexity, increases binary size, and introduces security risks from unmaintained code.
Module Overview
github.com/xeipuuv/gojsonschema is a JSON Schema validator for Go supporting draft-04, draft-06, and draft-07. It provides validation with custom formats, localization, and detailed error reporting.
Version: v1.2.0 (October 2019)⚠️ UNMAINTAINED
Repository Status:
Current Usage in gh-aw
Single file:
pkg/campaign/validation.goThe module validates
CampaignSpecstructs against an embedded JSON schema (campaign_spec_schema.json) to ensure campaign configurations are valid before processing.Usage Pattern:
embed.FSgojsonschema.Validate()Test Coverage: Excellent - 13 comprehensive test cases covering edge cases
Research Findings
Repository Health 🔴
Key Limitations
❌ No support for draft 2019-09 or 2020-12
❌ Unmaintained for 5+ years
❌ Confusing error messages for
anyOf/oneOf(#214)❌ No response to security or feature requests
❌ Multiple users reporting they've migrated away
What It Does Well
✅ Draft-04/06/07 support works correctly
✅ Custom format checkers
✅ Detailed error context
✅ No known security vulnerabilities in current version
Improvement Opportunities
🏃 Quick Win #1: Consolidate to santhosh-tekuri/jsonschema/v6
Impact: HIGH 🔴
Effort: Low (1-2 hours)
Priority: IMMEDIATE
Why:
pkg/workflow/andpkg/parser/use santhosh-tekuri/jsonschema/v6Migration Example:
Benefits:
📐 Best Practice #2: Add Schema Caching
Current: Schema is loaded from
embed.FSand compiled on every validation callBetter: Follow the pattern used in
pkg/workflow/schema_validation.go:Impact: Minor performance improvement, but excellent for consistency with workflow validation
🔧 General Code Improvements
Enhanced Error Messages
Documentation
Recommendations
Priority 1: Migrate to santhosh-tekuri/jsonschema/v6 🔴
Why now:
Steps:
pkg/campaign/validation.go(~50 lines)github.com/xeipuuv/gojsonschemafromgo.modEstimated Effort: 1-2 hours
Risk: Very low (comprehensive tests + proven alternative)
Priority 2: Document Decision (If Migration Deferred)
If migration must wait, add a comment to
validation.go:However, this is NOT recommended because:
Next Steps
specs/mods/gojsonschema.mdModule Summary:
specs/mods/gojsonschema.mdGenerated by: Go Fan 🐹
Review Date: 2025-12-14
Beta Was this translation helpful? Give feedback.
All reactions