fix: return original error in PathOrCidPath fallback (#11059)
PathOrCidPath was returning the error from the second path.NewPath call instead of the original error when both attempts failed. This fix preserves the first error before attempting the fallback, ensuring users get the most relevant error message about their input.
Adam committed
Nov 16, 2025 at 17:45 UTC
35d26e143f3a9a23f1afd19f62fc48e17723915a
1 file changed
+4
-1
core/commands/cmdutils/utils.go
+4
-1
@@ -74,10 +74,13 @@ func PathOrCidPath(str string) (path.Path, error) {
74
return p, nil
75
}
76
77
+ // Save the original error before attempting fallback
78
+ originalErr := err
79
+
80
if p, err := path.NewPath("/ipfs/" + str); err == nil {
81
return p, nil
82
}
83
84
// Send back original err.
82
- return nil, err
85
+ return nil, originalErr
86
}