third_party/go-json-experiment: skip aliases absent from target package#614
Conversation
|
/cc @liggitt |
|
this subtree is imported as is from json-experimental ... any changes to it will be lost when we rerun the import script I don't think we need to update the generator, just delete the SkipFunc and DiscardUnknownMembers bits. The next time we update json-experimental, we'll update to HEAD and it will be compatible with json/v2 stdlib It would probably also be good to add a ci-pipline variant for go tip here as long as we have this json/v2 dep |
The generated alias.go forwarded SkipFunc and DiscardUnknownMembers to encoding/json/v2, but stdlib v2 dropped those symbols when JSONv2 graduated to baseline in golang/go@e62d3e6e. Every consumer that transitively imports kube-openapi broke under GOEXPERIMENT=jsonv2 (the default after e62d3e6e). Manually delete just those two declarations from alias.go. alias_gen.go itself is left untouched - this subtree is imported as-is from github.com/go-json-experiment/json, so any local generator changes would be lost on the next hack/update-json-library.sh run. When the pin is eventually bumped to go-json-experiment HEAD the regenerated alias.go will already be aligned with stdlib v2. Refs: - go-json-experiment/json#201 - go-json-experiment/json#203 - kubernetes/kubernetes#139159 Also add a ci-go-tip informational lane to .github/workflows/ci.yml so future stdlib drift through this shim is caught here rather than downstream in kubernetes/kubernetes. The lane uses continue-on-error and is not part of the required-checks aggregator. Signed-off-by: Davanum Srinivas <davanum@gmail.com>
| - name: Run verify scripts | ||
| run: | | ||
| ./hack/verify-go-directive.sh 1.24.0 | ||
| ci-go-tip: |
There was a problem hiding this comment.
Thanks! Making a note that we'll add a periodic test for this as well since it's only presubmit at the moment.
|
/lgtm |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dims, Jefftree, liggitt The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
thanks, @Jefftree, can you open a bump PR in k/k once this merges? |
👍 |
The alias generator forwarded every exported declaration from the vendored go-json-experiment shim to the target stdlib package (encoding/json/v2). When stdlib v2 dropped symbols that still exist in the pinned upstream snapshot - SkipFunc and DiscardUnknownMembers after JSONv2 graduated to baseline in golang/go@e62d3e6e - the generated alias.go referenced undefined symbols and broke every consumer transitively importing kube-openapi.
Teach alias_gen.go to load the target package's exported top-level declarations via go/build and go/parser, and emit aliases only for names present there. The check is applied to const, var, type, and non-method function declarations.
Regenerate alias.go for encoding/json/v2; SkipFunc and DiscardUnknownMembers are dropped. Builds clean under both GOEXPERIMENT=jsonv2 and GOEXPERIMENT=nojsonv2.