From 7ae411a4c2106106bd541b8c34314fa22678ba8b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20Ros=C5=82aniec?=
Date: Sat, 23 May 2026 13:32:58 +0000
Subject: [PATCH] fix(ci): unblock Dependabot upgrades to pflag/cobra/x-time
Three pre-existing fragilities surface when bumping deps:
1. pkg/cmd/flag/*_test.go used reflect.DeepEqual on error values.
pflag 1.0.7+ wraps underlying parse errors with fmt.Errorf(...: %w),
producing a different concrete type even when the rendered message
is identical. Switch to comparing err.Error() strings via a small
errorMessage(err) helper in flag_helpers_test.go.
2. expectedError literals previously used fmt.Errorf with a format
string; switched to errors.New with concatenation. Removes Go 1.24
vet's 'non-constant format string' concern for future churn.
3. CI: gotestsum v1.12.0 transitively imports golang.org/x/tools v0.19.0,
which fails to compile on Go 1.25 (invalid array length -delta*delta
in tokeninternal.go:64). Once any dep bump pushes go.mod past go
1.24.0 (e.g. x/time v0.15+), the 'Install gotestsum' step fails.
Bump to gotestsum v1.13.0, which pulls newer x/tools that compiles
on both 1.24 and 1.25.
Smoke-tested locally against the three currently-open Dependabot PR
targets:
- pflag 1.0.6 -> 1.0.10: pkg/cmd/flag tests green
- cobra 1.10.2 + pflag 1.0.9: pkg/cmd tests green
- gotestsum v1.13.0: installs cleanly on Go 1.24 and Go 1.25
---
.github/workflows/client.yml | 2 +-
pkg/cmd/flag/flag_big_int_test.go | 11 +++++------
pkg/cmd/flag/flag_helpers_test.go | 12 ++++++++++++
pkg/cmd/flag/flag_wei_test.go | 17 ++++++++---------
4 files changed, 26 insertions(+), 16 deletions(-)
create mode 100644 pkg/cmd/flag/flag_helpers_test.go
diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml
index 91964f2..0287730 100644
--- a/.github/workflows/client.yml
+++ b/.github/workflows/client.yml
@@ -34,7 +34,7 @@ jobs:
run: go build ./...
- name: Install gotestsum
- run: go install gotest.tools/gotestsum@v1.12.0
+ run: go install gotest.tools/gotestsum@v1.13.0
- name: Run Go tests
run: gotestsum
diff --git a/pkg/cmd/flag/flag_big_int_test.go b/pkg/cmd/flag/flag_big_int_test.go
index 7f90a28..d753aef 100644
--- a/pkg/cmd/flag/flag_big_int_test.go
+++ b/pkg/cmd/flag/flag_big_int_test.go
@@ -1,9 +1,8 @@
package flag
import (
- "fmt"
+ "errors"
"math/big"
- "reflect"
"testing"
pflag "github.com/spf13/pflag"
@@ -25,9 +24,9 @@ func TestBigIntVarFlag_Set(t *testing.T) {
},
"invalid value": {
value: "100k",
- expectedError: fmt.Errorf(
- "invalid argument \"100k\" for \"--%s\" flag: failed to parse as big.Int: 100k",
- bigIntFlagName,
+ expectedError: errors.New(
+ "invalid argument \"100k\" for \"--" + bigIntFlagName +
+ "\" flag: failed to parse as big.Int: 100k",
),
expectedValue: defaultValue,
},
@@ -43,7 +42,7 @@ func TestBigIntVarFlag_Set(t *testing.T) {
err := flags.Set(bigIntFlagName, test.value)
- if !reflect.DeepEqual(test.expectedError, err) {
+ if errorMessage(err) != errorMessage(test.expectedError) {
t.Errorf(
"unexpected error\nexpected: %v\nactual: %v\n",
test.expectedError,
diff --git a/pkg/cmd/flag/flag_helpers_test.go b/pkg/cmd/flag/flag_helpers_test.go
new file mode 100644
index 0000000..53c0fc8
--- /dev/null
+++ b/pkg/cmd/flag/flag_helpers_test.go
@@ -0,0 +1,12 @@
+package flag
+
+// errorMessage returns err.Error() or "" if err is nil. Used to compare error
+// equality by message string rather than by concrete type, since pflag wraps
+// underlying errors with fmt.Errorf("...: %w", inner) — the rendered message
+// stays stable across pflag versions but the concrete type does not.
+func errorMessage(err error) string {
+ if err == nil {
+ return ""
+ }
+ return err.Error()
+}
diff --git a/pkg/cmd/flag/flag_wei_test.go b/pkg/cmd/flag/flag_wei_test.go
index 498d0d4..bfadce0 100644
--- a/pkg/cmd/flag/flag_wei_test.go
+++ b/pkg/cmd/flag/flag_wei_test.go
@@ -1,9 +1,8 @@
package flag
import (
- "fmt"
+ "errors"
"math/big"
- "reflect"
"testing"
"github.com/keep-network/keep-common/pkg/chain/ethereum"
@@ -37,16 +36,16 @@ func TestWeiVarFlag_Set(t *testing.T) {
},
"value with invalid comma delimiter": {
value: "3,5 ether",
- expectedError: fmt.Errorf(
- "invalid argument \"3,5 ether\" for \"--%s\" flag: failed to parse value: [3,5 ether]",
- flagName,
+ expectedError: errors.New(
+ "invalid argument \"3,5 ether\" for \"--" + flagName +
+ "\" flag: failed to parse value: [3,5 ether]",
),
},
"value with invalid unit": {
value: "10 bei",
- expectedError: fmt.Errorf(
- "invalid argument \"10 bei\" for \"--%s\" flag: invalid unit: bei; please use one of: ether, gwei, wei",
- flagName,
+ expectedError: errors.New(
+ "invalid argument \"10 bei\" for \"--" + flagName +
+ "\" flag: invalid unit: bei; please use one of: ether, gwei, wei",
),
},
}
@@ -61,7 +60,7 @@ func TestWeiVarFlag_Set(t *testing.T) {
err := flags.Set(flagName, test.value)
- if !reflect.DeepEqual(test.expectedError, err) {
+ if errorMessage(err) != errorMessage(test.expectedError) {
t.Errorf(
"unexpected error\nexpected: %v\nactual: %v\n",
test.expectedError,