Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bump version of jsonpatch for lossy max int64 #4090

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,5 @@ require (
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace gomodules.xyz/jsonpatch/v2 => github.com/lacroixthomas/jsonpatch/v2 v2.0.0-20250120171921-4c723fc27712
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lacroixthomas/jsonpatch/v2 v2.0.0-20250120171921-4c723fc27712 h1:HR2sgBlQ9650M2v36F5lmSMKCKXsmrQkwhXx6ECPUe4=
github.com/lacroixthomas/jsonpatch/v2 v2.0.0-20250120171921-4c723fc27712/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY=
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
Expand Down Expand Up @@ -709,8 +711,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw=
gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY=
google.golang.org/api v0.0.0-20180603000442-8e296ef26005/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
Expand Down
17 changes: 12 additions & 5 deletions vendor/gomodules.xyz/jsonpatch/v2/jsonpatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ func CreatePatch(a, b []byte) ([]Operation, error) {
}
var aI interface{}
var bI interface{}
err := json.Unmarshal(a, &aI)
if err != nil {
aDec := json.NewDecoder(bytes.NewReader(a))
aDec.UseNumber()
if err := aDec.Decode(&aI); err != nil {
return nil, errBadJSONDoc
}
err = json.Unmarshal(b, &bI)
if err != nil {
bDec := json.NewDecoder(bytes.NewReader(b))
bDec.UseNumber()
if err := bDec.Decode(&bI); err != nil {
return nil, errBadJSONDoc
}
return handleValues(aI, bI, "", []Operation{})
Expand All @@ -94,6 +96,11 @@ func matchesValue(av, bv interface{}) bool {
if ok && bt == at {
return true
}
case json.Number:
bt, ok := bv.(json.Number)
if ok && bt == at {
return true
}
case float64:
bt, ok := bv.(float64)
if ok && bt == at {
Expand Down Expand Up @@ -212,7 +219,7 @@ func handleValues(av, bv interface{}, p string, patch []Operation) ([]Operation,
if err != nil {
return nil, err
}
case string, float64, bool:
case string, float64, bool, json.Number:
if !matchesValue(av, bv) {
patch = append(patch, NewOperation("replace", p, bv))
}
Expand Down
3 changes: 2 additions & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ golang.org/x/tools/internal/gocommand
golang.org/x/tools/internal/gopathwalk
golang.org/x/tools/internal/imports
golang.org/x/tools/internal/stdlib
# gomodules.xyz/jsonpatch/v2 v2.4.0
# gomodules.xyz/jsonpatch/v2 v2.4.0 => github.com/lacroixthomas/jsonpatch/v2 v2.0.0-20250120171921-4c723fc27712
## explicit; go 1.20
gomodules.xyz/jsonpatch/v2
# google.golang.org/api v0.138.0
Expand Down Expand Up @@ -1139,3 +1139,4 @@ sigs.k8s.io/structured-merge-diff/v4/value
## explicit; go 1.12
sigs.k8s.io/yaml
sigs.k8s.io/yaml/goyaml.v2
# gomodules.xyz/jsonpatch/v2 => github.com/lacroixthomas/jsonpatch/v2 v2.0.0-20250120171921-4c723fc27712
Loading