fix: return original error in PathOrCidPath fallback

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.
This commit is contained in:
Adam 2025-11-15 09:59:48 +01:00 committed by GitHub
parent cec7432043
commit cc73d23001
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
}