From c669893c7fc7282d38f68eb4cc0b9227b5ce32ce Mon Sep 17 00:00:00 2001 From: "red-hat-konflux-kflux-prd-rh02[bot]" <190377777+red-hat-konflux-kflux-prd-rh02[bot]@users.noreply.github.com> Date: Sat, 8 Aug 2026 00:14:51 +0000 Subject: [PATCH] Update module github.com/knadh/koanf/v2 to v2.3.6 Signed-off-by: red-hat-konflux-kflux-prd-rh02 <190377777+red-hat-konflux-kflux-prd-rh02[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 +-- vendor/github.com/knadh/koanf/v2/koanf.go | 39 ++++++++++++++++++++++- vendor/modules.txt | 2 +- 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 1a6cd25fd..3201c8fa4 100644 --- a/go.mod +++ b/go.mod @@ -127,7 +127,7 @@ require ( github.com/klauspost/compress v1.18.7 // indirect github.com/knadh/koanf/maps v0.1.2 // indirect github.com/knadh/koanf/providers/confmap v1.0.0 // indirect - github.com/knadh/koanf/v2 v2.3.5 // indirect + github.com/knadh/koanf/v2 v2.3.6 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.24 // indirect diff --git a/go.sum b/go.sum index a7c8344a6..927a0222b 100644 --- a/go.sum +++ b/go.sum @@ -331,8 +331,8 @@ github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpb github.com/knadh/koanf/maps v0.1.2/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= github.com/knadh/koanf/providers/confmap v1.0.0 h1:mHKLJTE7iXEys6deO5p6olAiZdG5zwp8Aebir+/EaRE= github.com/knadh/koanf/providers/confmap v1.0.0/go.mod h1:txHYHiI2hAtF0/0sCmcuol4IDcuQbKTybiB1nOcUo1A= -github.com/knadh/koanf/v2 v2.3.5 h1:2dXJUYaKGm4SGYeoAtBviq9+02JZo/pxQ2ssOd60rJg= -github.com/knadh/koanf/v2 v2.3.5/go.mod h1:gRb40VRAbd4iJMYYD5IxZ6hfuopFcXBpc9bbQpZwo28= +github.com/knadh/koanf/v2 v2.3.6 h1:JoQPSJmvS4aP0xNc8xMDr5tcrkSEInL23/Il7pITAKo= +github.com/knadh/koanf/v2 v2.3.6/go.mod h1:gRb40VRAbd4iJMYYD5IxZ6hfuopFcXBpc9bbQpZwo28= github.com/kolo/xmlrpc v0.0.0-20220921171641-a4b6fa1dd06b h1:udzkj9S/zlT5X367kqJis0QP7YMxobob6zhzq6Yre00= github.com/kolo/xmlrpc v0.0.0-20220921171641-a4b6fa1dd06b/go.mod h1:pcaDhQK0/NJZEvtCO0qQPPropqV0sJOJ6YW7X+9kRwM= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= diff --git a/vendor/github.com/knadh/koanf/v2/koanf.go b/vendor/github.com/knadh/koanf/v2/koanf.go index 5c7abe6d5..fb57a50e3 100644 --- a/vendor/github.com/knadh/koanf/v2/koanf.go +++ b/vendor/github.com/knadh/koanf/v2/koanf.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding" "fmt" + "math" "reflect" "sort" "strconv" @@ -483,17 +484,53 @@ func toInt64(v any) (int64, error) { return int64(i), nil case int64: return i, nil + case uint8: + return int64(i), nil + case uint16: + return int64(i), nil + case uint32: + return int64(i), nil + case uint: + return uintToInt64(uint64(i)) + case uint64: + return uintToInt64(i) } // Force it to a string and try to convert. - f, err := strconv.ParseFloat(fmt.Sprintf("%v", v), 64) + s := fmt.Sprintf("%v", v) + + // Try parsing as int64 first, and on failure, attempt float64 parsing. + // Parsing directly as float64, when the number is beyond its upper limit (2^53) + // causes unnecessary precision loss when the value is actually an int. + if i, err := strconv.ParseInt(s, 10, 64); err == nil { + return i, nil + } + + f, err := strconv.ParseFloat(s, 64) if err != nil { return 0, err } + // int64(f) is undefined for numbers that are out of range and returns different + // results on different architectures. float64 cannot exactly represent MaxInt64, + // so check against the ACTUAL upper limit of 2^63. + // If neither match, return an error instead of the undefined result. + if math.IsNaN(f) || f < math.MinInt64 || f >= 1<<63 { + return 0, fmt.Errorf("value %v overflows int64", v) + } + return int64(f), nil } +// uintToInt64 converts an unsigned integer to int64 and throw an error on overflow. +func uintToInt64(v uint64) (int64, error) { + if v > math.MaxInt64 { + return 0, fmt.Errorf("value %d overflows int64", v) + } + + return int64(v), nil +} + // toInt64 takes a `v any` value and if it is a float type, // converts and returns a `float64`. If it's any other type, forces it to a // string and attempts to get a float out using `strconv.ParseFloat`. diff --git a/vendor/modules.txt b/vendor/modules.txt index 717f5f7c6..930a1d85c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -517,7 +517,7 @@ github.com/knadh/koanf/maps # github.com/knadh/koanf/providers/confmap v1.0.0 ## explicit; go 1.23.0 github.com/knadh/koanf/providers/confmap -# github.com/knadh/koanf/v2 v2.3.5 +# github.com/knadh/koanf/v2 v2.3.6 ## explicit; go 1.23.0 github.com/knadh/koanf/v2 # github.com/kylelemons/godebug v1.1.0