Skip to content

swap to a different jsonschema library#167

Merged
chrisghill merged 2 commits into
mainfrom
chris/bugfix/swap-jsonschema-libraries
Jul 4, 2025
Merged

swap to a different jsonschema library#167
chrisghill merged 2 commits into
mainfrom
chris/bugfix/swap-jsonschema-libraries

Conversation

@chrisghill

@chrisghill chrisghill commented Jul 3, 2025

Copy link
Copy Markdown
Member

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.

@chrisghill chrisghill requested a review from coryodaniel as a code owner July 3, 2025 23:26
@chrisghill chrisghill requested a review from Copilot July 4, 2025 04:10

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 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/Reader and ValidateFile/Bytes/Go functions and removes gojsonschema usage.
  • Updates commands, publishing, artifact import, bundle linting, and dereferencing to use the new API.
  • Cleans up dependencies in go.mod and 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...")

@chrisghill chrisghill merged commit 4847356 into main Jul 4, 2025
3 of 4 checks passed
@chrisghill chrisghill deleted the chris/bugfix/swap-jsonschema-libraries branch July 4, 2025 16:00
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