feat: upgrade yaml library from gopkg.in/yaml.v3 to go.yaml.in/yaml/v4#163
feat: upgrade yaml library from gopkg.in/yaml.v3 to go.yaml.in/yaml/v4#163TristanSpeakEasy wants to merge 3 commits intomainfrom
Conversation
📊 Test Coverage ReportCurrent Coverage: Coverage Change: ✅ No change Coverage by Package
📋 Detailed Coverage by Function (click to expand)
Generated by GitHub Actions |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR upgrades the codebase’s YAML implementation from gopkg.in/yaml.v3 to go.yaml.in/yaml/v4 (v4.0.0-rc.4), including adapting marshalling/unmarshalling error handling and updating tests. It also introduces an unsafe bridge in the overlay JSONPath integration to interoperate with JSONPath libraries that still expose yaml.v3 *Node types.
Changes:
- Replace
gopkg.in/yaml.v3imports withgo.yaml.in/yaml/v4across the repository (including nested modules). - Add v4↔v3 node bridging for JSONPath query execution (overlay + tests) using
unsafe.Pointer. - Update unmarshalling error handling (
yaml.TypeError→yaml.LoadErrors) and adjust tests for updated v4 error/type strings.
Reviewed changes
Copilot reviewed 169 out of 174 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| yml/yml_test.go | Switch YAML import to v4 (tests). |
| yml/yml.go | Switch YAML import to v4. |
| yml/walk_test.go | Switch YAML import to v4 (tests). |
| yml/walk.go | Switch YAML import to v4. |
| yml/nodekind_test.go | Switch YAML import to v4 (tests). |
| yml/nodekind.go | Switch YAML import to v4. |
| yml/config_test.go | Switch YAML import to v4 (tests). |
| yml/config.go | Switch YAML import to v4. |
| values/value.go | Switch YAML import to v4. |
| values/core/value.go | Switch YAML import to v4. |
| values/core/eithervalue_test.go | Switch YAML import to v4 (tests). |
| values/core/eithervalue.go | Switch YAML import to v4. |
| validation/validation_test.go | Switch YAML import to v4 (tests). |
| validation/utils_test.go | Switch YAML import to v4 (tests). |
| validation/fix.go | Switch YAML import to v4. |
| validation/errors.go | Switch YAML import to v4. |
| swagger/roundtrip_test.go | Switch YAML import to v4 (tests). |
| swagger/core/response_test.go | Switch YAML import to v4 (tests). |
| swagger/core/response.go | Switch YAML import to v4. |
| swagger/core/reference_test.go | Switch YAML import to v4 (tests). |
| swagger/core/reference.go | Switch YAML import to v4. |
| swagger/core/paths_test.go | Switch YAML import to v4 (tests). |
| swagger/core/paths.go | Switch YAML import to v4. |
| sequencedmap/yaml_unmarshal_test.go | Switch YAML import to v4 (tests). |
| sequencedmap/map_advanced_test.go | Switch YAML import to v4 (tests). |
| sequencedmap/map.go | Switch YAML import to v4. |
| references/resolution_test.go | Switch YAML import to v4 (tests). |
| references/resolution.go | Switch YAML import to v4. |
| overlay/validate_test.go | Switch YAML import to v4 (tests). |
| overlay/utils_test.go | Switch YAML import to v4 (tests). |
| overlay/utils.go | Switch YAML import to v4. |
| overlay/upgrade_test.go | Switch YAML import to v4 (tests). |
| overlay/schema.go | Switch YAML import to v4. |
| overlay/parse.go | Switch YAML import to v4. |
| overlay/parents.go | Switch YAML import to v4. |
| overlay/overlay_examples_test.go | Switch YAML import to v4 (examples/tests). |
| overlay/loader/spec_test.go | Switch YAML import to v4 (tests). |
| overlay/loader/spec.go | Switch YAML import to v4. |
| overlay/jsonpath.go | Add unsafe v4↔v3 node bridge + wrap JSONPath queryables to accept v4 nodes. |
| overlay/format_test.go | Switch YAML import to v4 (tests). |
| overlay/compare_test.go | Switch YAML import to v4 (tests). |
| overlay/compare.go | Switch YAML import to v4. |
| overlay/apply_test.go | Add v4-compatible JSONPath query helper via v3 bridge; switch YAML import to v4. |
| overlay/apply.go | Switch YAML import to v4. |
| openapi/upgrade_test.go | Switch YAML import to v4 (tests). |
| openapi/upgrade.go | Switch YAML import to v4. |
| openapi/sanitize.go | Switch YAML import to v4. |
| openapi/reference.go | Switch YAML import to v4. |
| openapi/openapi_examples_test.go | Update expected error message text for yaml v4 (“cannot unmarshal” → “cannot construct”). |
| openapi/openapi.go | Switch YAML import to v4. |
| openapi/localize.go | Switch YAML import to v4. |
| openapi/linter/rules/unused_components.go | Switch YAML import to v4. |
| openapi/linter/rules/typed_enum.go | Switch YAML import to v4. |
| openapi/linter/rules/tags_alphabetical.go | Switch YAML import to v4. |
| openapi/linter/rules/rule_fixes_test.go | Switch YAML import to v4 (tests). |
| openapi/linter/rules/path_trailing_slash.go | Switch YAML import to v4. |
| openapi/linter/rules/owasp_security_hosts_https_oas3.go | Switch YAML import to v4. |
| openapi/linter/rules/owasp_no_additional_properties.go | Switch YAML import to v4. |
| openapi/linter/rules/owasp_jwt_best_practices.go | Switch YAML import to v4. |
| openapi/linter/rules/operation_success_response.go | Switch YAML import to v4. |
| openapi/linter/rules/oas_schema_check.go | Switch YAML import to v4. |
| openapi/linter/rules/oas3_no_nullable.go | Switch YAML import to v4. |
| openapi/linter/rules/markdown_descriptions.go | Switch YAML import to v4. |
| openapi/linter/rules/host_trailing_slash.go | Switch YAML import to v4. |
| openapi/linter/rules/fix_integration_test.go | Switch YAML import to v4 (tests). |
| openapi/linter/rules/fix_helpers_test.go | Switch YAML import to v4 (tests). |
| openapi/linter/rules/fix_helpers.go | Switch YAML import to v4. |
| openapi/linter/rules/duplicated_entry_in_enum.go | Switch YAML import to v4. |
| openapi/linter/rules/description_duplication.go | Switch YAML import to v4. |
| openapi/linter/linter_test.go | Switch YAML import to v4 (tests). |
| openapi/linter/customrules/runtime.go | Switch YAML import to v4. |
| openapi/linter/customrules/go.mod | Replace direct yaml.v3 with yaml.v4; keep yaml.v3 indirect. |
| openapi/linter/customrules/go.sum | Add yaml.v4 checksums. |
| openapi/linter/converter/tests/go.mod | Add yaml.v4 as indirect. |
| openapi/linter/converter/tests/go.sum | Add yaml.v4 checksums. |
| openapi/linter/converter/parse.go | Switch YAML import to v4. |
| openapi/linter/converter/generate_test.go | Switch YAML import to v4 (tests). |
| openapi/linter/converter/generate.go | Switch YAML import to v4. |
| openapi/index_node_operation_test.go | Switch YAML import to v4 (tests). |
| openapi/index.go | Switch YAML import to v4. |
| openapi/core/security_test.go | Switch YAML import to v4 (tests). |
| openapi/core/security.go | Switch YAML import to v4. |
| openapi/core/responses_test.go | Switch YAML import to v4 (tests). |
| openapi/core/responses.go | Switch YAML import to v4. |
| openapi/core/reference_test.go | Switch YAML import to v4 (tests). |
| openapi/core/reference.go | Switch YAML import to v4. |
| openapi/core/paths_test.go | Switch YAML import to v4 (tests). |
| openapi/core/paths.go | Switch YAML import to v4. |
| openapi/core/callbacks_test.go | Switch YAML import to v4 (tests). |
| openapi/core/callbacks.go | Switch YAML import to v4. |
| openapi/bootstrap_test.go | Switch YAML import to v4 (tests). |
| marshaller/unmarshalling_test.go | Update expected error messages for yaml v4 (“cannot unmarshal” → “cannot construct”). |
| marshaller/unmarshaller.go | Use yaml.LoadErrors (v4) for type mismatch collection; convert contained errors to strings. |
| marshaller/tests/models.go | Switch YAML import to v4 (test models). |
| marshaller/tests/core/models.go | Switch YAML import to v4 (test models). |
| marshaller/syncing_test.go | Switch YAML import to v4 (tests). |
| marshaller/syncer.go | Switch YAML import to v4. |
| marshaller/sequencedmap_test.go | Switch YAML import to v4 (tests). |
| marshaller/sequencedmap.go | Switch YAML import to v4. |
| marshaller/populator_unmarshalextensionmodel_test.go | Switch YAML import to v4 (tests). |
| marshaller/populator.go | Switch YAML import to v4. |
| marshaller/nodecollector_test.go | Switch YAML import to v4 (tests). |
| marshaller/nodecollector.go | Switch YAML import to v4. |
| marshaller/node_test.go | Switch YAML import to v4 (tests). |
| marshaller/node.go | Switch YAML import to v4. |
| marshaller/model_test.go | Switch YAML import to v4 (tests). |
| marshaller/model.go | Switch YAML import to v4. |
| marshaller/marshal.go | Switch YAML import to v4. |
| marshaller/factory.go | Switch YAML import to v4. |
| marshaller/extensions.go | Switch YAML import to v4. |
| marshaller/coremodel_jsonpointer_test.go | Switch YAML import to v4 (tests). |
| marshaller/coremodel_jsonpath_test.go | Add v4-compatible JSONPath query helper via v3 bridge; switch YAML import to v4. |
| marshaller/coremodel_getters_test.go | Switch YAML import to v4 (tests). |
| marshaller/coremodel.go | Switch YAML import to v4. |
| linter/format/format_test.go | Switch YAML import to v4 (tests). |
| linter/fix/terminal_prompter_test.go | Switch YAML import to v4 (tests). |
| linter/fix/engine_test.go | Switch YAML import to v4 (tests). |
| linter/fix/engine.go | Switch YAML import to v4. |
| linter/config_loader.go | Switch YAML import to v4. |
| linter/config.go | Switch YAML import to v4. |
| jsonschema/oas3/validation.go | Switch YAML import to v4. |
| jsonschema/oas3/tests/go.mod | Add yaml.v4 as indirect. |
| jsonschema/oas3/tests/go.sum | Add yaml.v4 checksums. |
| jsonschema/oas3/schema_validate_test.go | Update expected error message text for yaml v4. |
| jsonschema/oas3/schema_isequal_test.go | Switch YAML import to v4 (tests). |
| jsonschema/oas3/schema_getters_test.go | Switch YAML import to v4 (tests). |
| jsonschema/oas3/schema_exclusive_validation_test.go | Update expected error message text for yaml v4. |
| jsonschema/oas3/resolution_test.go | Switch YAML import to v4 (tests). |
| jsonschema/oas3/resolution_external_test.go | Switch YAML import to v4 (tests). |
| jsonschema/oas3/resolution_external.go | Switch YAML import to v4. |
| jsonschema/oas3/resolution_defs_test.go | Switch YAML import to v4 (tests). |
| jsonschema/oas3/resolution_defs.go | Switch YAML import to v4. |
| jsonschema/oas3/resolution.go | Switch YAML import to v4. |
| jsonschema/oas3/jsonschema_validate_test.go | Update expected error message text for yaml v4. |
| jsonschema/oas3/core/xml_test.go | Switch YAML import to v4 (tests). |
| jsonschema/oas3/core/jsonschema_test.go | Switch YAML import to v4 (tests). |
| jsonpointer/yamlnode_test.go | Switch YAML import to v4 (tests). |
| jsonpointer/yamlnode.go | Switch YAML import to v4. |
| jsonpointer/models_yaml_fallback_test.go | Update expected reflected type strings (*yaml.Node → *libyaml.Node); switch YAML import to v4 (tests). |
| jsonpointer/jsonpointer.go | Switch YAML import to v4. |
| json/json_test.go | Switch YAML import to v4 (tests). |
| json/json.go | Switch YAML import to v4. |
| internal/testutils/utils_test.go | Switch YAML import to v4 (tests). |
| internal/testutils/utils.go | Switch YAML import to v4. |
| internal/interfaces/interfaces_test.go | Switch YAML import to v4 (tests). |
| internal/interfaces/interfaces.go | Switch YAML import to v4. |
| hashing/hashing_test.go | Switch YAML import to v4 (tests). |
| hashing/hashing.go | Switch YAML import to v4. |
| extensions/extensions_test.go | Switch YAML import to v4 (tests). |
| extensions/extensions_isequal_test.go | Switch YAML import to v4 (tests). |
| extensions/extensions.go | Switch YAML import to v4. |
| extensions/core/extensions_test.go | Switch YAML import to v4 (tests). |
| extensions/core/extensions.go | Switch YAML import to v4. |
| expression/value_test.go | Switch YAML import to v4 (tests). |
| expression/value.go | Switch YAML import to v4. |
| expression/core/value.go | Switch YAML import to v4. |
| cmd/openapi/go.mod | Replace direct yaml.v3 with yaml.v4; keep yaml.v3 indirect. |
| cmd/openapi/go.sum | Add yaml.v4 checksums. |
| cmd/openapi/commands/overlay/compare.go | Switch YAML import to v4 (CLI). |
| cmd/openapi/commands/overlay/apply.go | Switch YAML import to v4 (CLI). |
| cmd/openapi/commands/openapi/bootstrap.go | Switch YAML import to v4 (CLI). |
| arazzo/successaction.go | Switch YAML import to v4. |
| arazzo/reusable.go | Switch YAML import to v4. |
| arazzo/requestbody_test.go | Switch YAML import to v4 (tests). |
| arazzo/criterion/condition.go | Switch YAML import to v4. |
| arazzo/core/reusable_test.go | Switch YAML import to v4 (tests). |
| arazzo/core/reusable.go | Switch YAML import to v4. |
| arazzo/core/criterion_test.go | Switch YAML import to v4 (tests). |
| arazzo/core/criterion_syncchanges_test.go | Switch YAML import to v4 (tests). |
| arazzo/core/criterion.go | Switch YAML import to v4. |
| arazzo/arazzo_test.go | Switch YAML import to v4 (tests). |
| arazzo/arazzo_order_test.go | Switch YAML import to v4 (tests). |
| go.mod | Add yaml v4 requirement (rc); retain yaml v3 requirement. |
| go.sum | Add yaml v4 checksums. |
Comments suppressed due to low confidence (1)
go.mod:14
- If the goal is for
gopkg.in/yaml.v3to be only an indirect dependency, note that the root module still requires it directly here. Given the new v3 bridge code, this may be intentional—if so, please align the PR description accordingly; if not, adjust the code/deps so v3 can truly remain indirect.
github.com/stretchr/testify v1.11.1
github.com/vmware-labs/yaml-jsonpath v0.3.2
go.yaml.in/yaml/v4 v4.0.0-rc.4
golang.org/x/sync v0.19.0
golang.org/x/text v0.34.0
gopkg.in/yaml.v3 v3.0.1
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
gopkg.in/yaml.v3togo.yaml.in/yaml/v4(v4.0.0-rc.4) across 160+ filesoverlay/jsonpath.gofor jsonpath libraries that still use yaml.v3*Nodetypesyaml.TypeError→yaml.LoadErrorsin marshaller to use non-deprecated API"cannot unmarshal"→"cannot construct") and type name changes (*yaml.Node→*libyaml.Node)Notes
gopkg.in/yaml.v3remains as a direct dependency inoverlay/jsonpath.go(for the v3↔v4 bridge used by jsonpath libraries) and as an indirect dependency forvmware-labs/yaml-jsonpathandspeakeasy-api/jsonpathwhich still use v3 in their APIs. These can be forked/upgraded separately.unsafe.Pointercast is guarded by aninit()function that usesreflectto verify the first 12 fields of v4.Node match v3.Node in name, offset, and size. If a future v4 release changes the struct layout, the guard will panic at startup rather than causing silent corruption.v4.0.0-rc.4(release candidate)Test plan
go test -count=1 ./...mise cipasses (format, lint, mod-tidy, test, integration, build)