From 35d26e143f3a9a23f1afd19f62fc48e17723915a Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 16 Nov 2025 17:45:44 +0100 Subject: [PATCH] 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. --- core/commands/cmdutils/utils.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/commands/cmdutils/utils.go b/core/commands/cmdutils/utils.go index 9ecfd1446..c793f516e 100644 --- a/core/commands/cmdutils/utils.go +++ b/core/commands/cmdutils/utils.go @@ -74,10 +74,13 @@ func PathOrCidPath(str string) (path.Path, error) { return p, nil } + // Save the original error before attempting fallback + originalErr := err + if p, err := path.NewPath("/ipfs/" + str); err == nil { return p, nil } // Send back original err. - return nil, err + return nil, originalErr }