Skip to content

Commit 35d26e1

Browse files
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.
1 parent cec7432 commit 35d26e1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

core/commands/cmdutils/utils.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,13 @@ func PathOrCidPath(str string) (path.Path, error) {
7474
return p, nil
7575
}
7676

77+
// Save the original error before attempting fallback
78+
originalErr := err
79+
7780
if p, err := path.NewPath("/ipfs/" + str); err == nil {
7881
return p, nil
7982
}
8083

8184
// Send back original err.
82-
return nil, err
85+
return nil, originalErr
8386
}

0 commit comments

Comments
 (0)