Skip to content

third_party/go-json-experiment: skip aliases absent from target package#614

Merged
k8s-ci-robot merged 1 commit into
kubernetes:masterfrom
dims:fix-jsonv2-baseline
May 19, 2026
Merged

third_party/go-json-experiment: skip aliases absent from target package#614
k8s-ci-robot merged 1 commit into
kubernetes:masterfrom
dims:fix-jsonv2-baseline

Conversation

@dims

@dims dims commented May 19, 2026

Copy link
Copy Markdown
Member

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.

@k8s-ci-robot k8s-ci-robot requested review from Jefftree and jpbetz May 19, 2026 13:27
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 19, 2026
@Jefftree

Copy link
Copy Markdown
Member

/cc @liggitt
ref: kubernetes/kubernetes#139159

@k8s-ci-robot k8s-ci-robot requested a review from liggitt May 19, 2026 13:36
@liggitt

liggitt commented May 19, 2026

Copy link
Copy Markdown
Member

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

Comment thread pkg/internal/third_party/go-json-experiment/json/alias_gen.go
@dims dims force-pushed the fix-jsonv2-baseline branch from 5c62eb4 to 93d7292 Compare May 19, 2026 19:52
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 19, 2026
@dims dims force-pushed the fix-jsonv2-baseline branch from 93d7292 to 5c62eb4 Compare May 19, 2026 20:00
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 19, 2026
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>
@dims dims force-pushed the fix-jsonv2-baseline branch from 5c62eb4 to b21e2e4 Compare May 19, 2026 20:04
Comment thread .github/workflows/ci.yml
- name: Run verify scripts
run: |
./hack/verify-go-directive.sh 1.24.0
ci-go-tip:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Making a note that we'll add a periodic test for this as well since it's only presubmit at the moment.

@liggitt

liggitt commented May 19, 2026

Copy link
Copy Markdown
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 19, 2026
@Jefftree

Copy link
Copy Markdown
Member

/lgtm
/approve

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 19, 2026
@liggitt

liggitt commented May 19, 2026

Copy link
Copy Markdown
Member

thanks, @Jefftree, can you open a bump PR in k/k once this merges?

@Jefftree

Copy link
Copy Markdown
Member

thanks, @Jefftree, can you open a bump PR in k/k once this merges?

👍

@k8s-ci-robot k8s-ci-robot merged commit bbf5c55 into kubernetes:master May 19, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants