diff --git a/gateway/errors.go b/gateway/errors.go index 79cedcee0..5647bf476 100644 --- a/gateway/errors.go +++ b/gateway/errors.go @@ -12,6 +12,7 @@ import ( "github.com/ipfs/boxo/gateway/assets" "github.com/ipfs/boxo/path/resolver" "github.com/ipfs/go-cid" + ipld "github.com/ipfs/go-ipld-format" "github.com/ipld/go-ipld-prime/datamodel" ) @@ -188,6 +189,10 @@ func isErrNotFound(err error) bool { return true } + if ipld.IsNotFound(err) { + return true + } + // Checks if err is of a type that does not implement the .Is interface and // cannot be directly compared to. Therefore, errors.Is cannot be used. for { diff --git a/gateway/gateway_test.go b/gateway/gateway_test.go index 031a184a5..7d97d405c 100644 --- a/gateway/gateway_test.go +++ b/gateway/gateway_test.go @@ -846,7 +846,7 @@ func TestErrorBubblingFromBackend(t *testing.T) { }) } - testError("500 Not Found from IPLD", &ipld.ErrNotFound{}, http.StatusInternalServerError) + testError("404 Not Found from IPLD", &ipld.ErrNotFound{}, http.StatusNotFound) testError("404 Not Found from path resolver", &resolver.ErrNoLink{}, http.StatusNotFound) testError("502 Bad Gateway", ErrBadGateway, http.StatusBadGateway) testError("504 Gateway Timeout", ErrGatewayTimeout, http.StatusGatewayTimeout)