swap to a different jsonschema library#167
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR replaces the unmaintained gojsonschema library with the actively maintained santhosh-tekuri/jsonschema library, updating schema loading, validation, and related code across the project.
- Introduces new
LoadSchemaFromFile/URL/Go/ReaderandValidateFile/Bytes/Gofunctions and removesgojsonschemausage. - Updates commands, publishing, artifact import, bundle linting, and dereferencing to use the new API.
- Cleans up dependencies in
go.modand adjusts logging in template cache code.
Reviewed Changes
Copilot reviewed 23 out of 27 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/templatecache/github_fetcher.go | Replaced structured slog logging with fmt.Println |
| pkg/templatecache/bundle_template_cache.go | Replaced slog.Info with fmt.Println |
| pkg/prettylogs/main.go | Added new Red style helper |
| pkg/jsonschema/validate.go | Added new ValidateFile/Bytes/Go functions, removed old Validate |
| pkg/jsonschema/loader.go | Implemented new compiler-based loaders, removed gojsonschema |
| pkg/jsonschema/validate_test.go | Expanded tests for new validate functions |
| pkg/jsonschema/loader_test.go | Added tests for all new loader functions |
| pkg/bundle/bundle.go | Added omitempty tags, updated YAML tags |
| pkg/bundle/lint.go | Switched lint to use new JSON schema library |
| pkg/bundle/lint_test.go | Updated tests to match new error messages |
| pkg/bundle/dereference.go & tests | Renamed dereference API and updated references |
| pkg/definition/publish.go | Switched artifact definition validation to new library |
| pkg/commands/artifact/import.go | Switched artifact import validation to new library |
| cmd/schema.go | Updated CLI to use LoadSchemaFromFile + ValidateFile + prettylogs |
| go.mod | Removed gojsonschema deps, added santhosh-tekuri/jsonschema/v6 |
Comments suppressed due to low confidence (6)
pkg/jsonschema/loader.go:33
- The call to filepath.IsLocal does not exist in Go's standard library and will cause a compile error. Replace it with filepath.IsAbs or another valid check to detect absolute paths.
if filepath.IsLocal(path) && !strings.HasPrefix(path, "./") {
pkg/bundle/bundle.go:42
- The YAML struct tag has a duplicated 'omitempty' modifier, which is invalid. Remove the extra 'omitempty' so it reads
yaml:"app,omitempty".
AppSpec *AppSpec `json:"app,omitempty" yaml:"app,omitempty,omitempty"`
pkg/templatecache/github_fetcher.go:57
- [nitpick] Switching from structured slog logging to fmt.Println may break log consistency. Consider reintroducing a logger interface or using slog.Info to maintain structured logging.
fmt.Println("Downloading templates from repo")
pkg/templatecache/github_fetcher.go:80
- [nitpick] Use the project’s structured logger instead of fmt.Println to keep logging consistent and configurable.
fmt.Println("Templates are current, skipping download!")
pkg/templatecache/github_fetcher.go:85
- [nitpick] Revert to using the structured logger (slog.Info) rather than fmt.Println to preserve uniform logging behavior.
fmt.Println("Pulling latest changes from repo")
pkg/templatecache/bundle_template_cache.go:41
- [nitpick] This replaces a structured slog.Info call with fmt.Println. For consistency and configurability, consider restoring structured logging here.
fmt.Println("Refreshing bundle templates...")
coryodaniel
approved these changes
Jul 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The previous json schema library (https://github.com/xeipuuv/gojsonschema) is unmaintained and there were intermittent issues when trying to load a schema via URL (specifically the new schema endpoints hosted by Massdriver).
I swapped to using a new JSON schema library (https://github.com/santhosh-tekuri/jsonschema). This consistently can pull and load schemas via URLs, it supports draft-7 as well as 2019 and 2020, and it is active with maintainers.