fix(gw): 404 when a valid DAG is missing link#9126
Merged
Conversation
lidel
commented
Jul 19, 2022
Comment on lines
+785
to
+786
| } else if ipld.IsNotFound(err) { | ||
| webErrorWithCode(w, message, err, http.StatusNotFound) |
Member
Author
There was a problem hiding this comment.
ℹ️ 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
iand
reviewed
Jul 21, 2022
| {"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"}, |
Contributor
There was a problem hiding this comment.
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
be10c71 to
0918d57
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.IsNotFoundadded in #8838Closes #8924
Closes #9064