-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(gw): 404 when a valid DAG is missing link #9126
Conversation
} else if ipld.IsNotFound(err) { | ||
webErrorWithCode(w, message, err, http.StatusNotFound) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️ this makes sure every webError
gets 404 when appropriate (even when it was called with http.StatusBadRequest
)
76c3f13
to
7062162
Compare
7062162
to
be10c71
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -235,17 +235,17 @@ func TestGatewayGet(t *testing.T) { | |||
{"127.0.0.1:8080", "/", http.StatusNotFound, "404 page not found\n"}, | |||
{"127.0.0.1:8080", "/" + k.Cid().String(), http.StatusNotFound, "404 page not found\n"}, | |||
{"127.0.0.1:8080", k.String(), http.StatusOK, "fnord"}, | |||
{"127.0.0.1:8080", "/ipns/nxdomain.example.com", http.StatusNotFound, "ipfs resolve -r /ipns/nxdomain.example.com: " + namesys.ErrResolveFailed.Error() + "\n"}, | |||
{"127.0.0.1:8080", "/ipns/%0D%0A%0D%0Ahello", http.StatusNotFound, "ipfs resolve -r /ipns/\\r\\n\\r\\nhello: " + namesys.ErrResolveFailed.Error() + "\n"}, | |||
{"127.0.0.1:8080", "/ipns/nxdomain.example.com", http.StatusBadRequest, "ipfs resolve -r /ipns/nxdomain.example.com: " + namesys.ErrResolveFailed.Error() + "\n"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note I think resolution errors should be reported as 502 Bad Gateway but that's not what the gateway spec says. I'll raise an issue there instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Continued in ipfs/specs#300 👍
be10c71
to
0918d57
Compare
This PR makes sure gateway returns 404 (Not Found) only when a valid DAG is missing the requested child.
In other cases, 400 (Bad Request) is returned.
Uses
ipld.IsNotFound
added in #8838Closes #8924
Closes #9064