openapi icon indicating copy to clipboard operation
openapi copied to clipboard

fix: replace gopkg.in/yaml.v3 with go.yaml.in/yaml/v3

Open sridhar-3009 opened this issue 6 months ago • 1 comments

Problem

gopkg.in/yaml.v3 is unmaintained and flagged by security scanners (kubernetes-sigs/yaml#117). It is no longer receiving updates.

Fix

Replace all usages across the codebase with go.yaml.in/yaml/v3, the canonical successor package maintained by the same upstream authors.

  • All Go import paths updated via batch find+replace
  • go.mod updated to go.yaml.in/yaml/v3 v3.0.4

The API is identical — no code logic changes, import path only.

Closes #201

sridhar-3009 avatar May 31 '26 08:05 sridhar-3009

Dependency migration follow-up discovered while addressing review feedback:

  • Direct cleanup is pushed in a985f2b: root, cmd/openapi, openapi/linter/customrules, jsonschema/oas3/tests, and openapi/linter/converter/tests were tidied with go.yaml.in/yaml/v3 v3.0.4; overlay/README.md was also updated.
  • External contributor diff review found no suspicious or unrelated code changes; the original PR diff is mechanical import-path replacement plus root module metadata.

Remaining blockers to track before this migration can fully pass builds/tests:

  1. github.com/speakeasy-api/jsonpath still exposes gopkg.in/yaml.v3 in its public API.

    • Latest release: v0.6.3.
    • Checked @main pseudo-version v0.6.4-0.20260215213553-5923067bd0c5; it still imports gopkg.in/yaml.v3.
    • This causes type mismatches in overlay/jsonpath.go and marshaller/coremodel_jsonpath_test.go because Go treats *go.yaml.in/yaml/v3.Node and *gopkg.in/yaml.v3.Node as distinct types.
  2. github.com/vmware-labs/yaml-jsonpath v0.3.2 also exposes gopkg.in/yaml.v3 nodes from Path.Find, causing the same mismatch in overlay/jsonpath.go.

  3. gopkg.in/yaml.v3 still appears indirectly in module graphs because transitive dependencies still require it (github.com/speakeasy-api/jsonpath, github.com/vmware-labs/yaml-jsonpath, plus test/tool dependency trees such as testify, cobra, and testcontainers). Manually deleting those indirect entries is not stable; go mod tidy restores them.

Validation notes:

  • Passing locally: go mod verify in all affected modules; go test ./... in openapi/linter/customrules, jsonschema/oas3/tests, and openapi/linter/converter/tests.
  • Failing locally due to dependency API blockers above: root go test ./... and cmd/openapi go test ./....
  • mise ci passes fmt + mod-check locally, then cannot complete because golangci-lint is not installed and the lint script hits BSD grep incompatibility (grep -P).

TristanSpeakEasy avatar Jun 01 '26 06:06 TristanSpeakEasy