Skip to content
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(gateway): return 500 for all /ip[nf]s/id failures #187

Merged
merged 1 commit into from
Feb 28, 2023
Merged

Conversation

hacdias
Copy link
Member

@hacdias hacdias commented Feb 27, 2023

@@ -352,9 +352,11 @@ 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", "/ipfs/this-is-not-a-cid", http.StatusInternalServerError, "failed to resolve /ipfs/this-is-not-a-cid: invalid path \"/ipfs/this-is-not-a-cid\": invalid CID: illegal base32 data at input byte 3\n"},
Copy link
Member Author

@hacdias hacdias Feb 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't like this tests where we compare the body for errors. Error information may change slightly depending on the backing implementation. I think rewriting these tests can be part of #156 or even #183.

Yes, we should compare the body for files we are expecting I think, and stuff like custom 404s, but not necessarily for errors. As long as the status is correct, the test should pass. Similarly to TestGatewayInternalServerErrorInvalidPath.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hacdias these don't do much for UX, but also we dont expect these messages to change often.

Once set in stone, make good canaries to hint someone in transitive dependencies messed up refactor :)
I would keep this, at least until go-libipfs/gateway and rhea work is in progress – better to have more tests than less.

I remember in the past an external library (like go-cid or go-multihash/base, don't remember which one) changed something, and we detected it in Kubo, 2 layers later, because a specific error message changed to a generic one.

ps. At some point we will add more friendly HTML error responses if a request was made with Accept that includes text/html (web browser), like we did for dag-cbor.

@codecov
Copy link

codecov bot commented Feb 27, 2023

Codecov Report

Merging #187 (067e56f) into main (0d5d1ca) will decrease coverage by 0.06%.
The diff coverage is 0.00%.

❗ Current head 067e56f differs from pull request most recent head 8108c45. Consider uploading reports for the commit 8108c45 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #187      +/-   ##
==========================================
- Coverage   29.75%   29.70%   -0.06%     
==========================================
  Files         100      100              
  Lines       11267    11263       -4     
==========================================
- Hits         3353     3346       -7     
- Misses       7548     7550       +2     
- Partials      366      367       +1     
Impacted Files Coverage Δ
gateway/handler.go 64.50% <0.00%> (-0.68%) ⬇️

@hacdias hacdias changed the title fix: return 500 for all /ip[nf]s/id failures fix(gateway): return 500 for all /ip[nf]s/id failures Feb 27, 2023
@hacdias hacdias marked this pull request as ready for review February 27, 2023 11:14
@hacdias hacdias requested a review from lidel as a code owner February 27, 2023 11:14
@hacdias hacdias self-assigned this Feb 27, 2023
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

Merging this to fix Kubo, unify behavior , and unblock future spec work around 502 and 504.

Comment on lines -584 to -585
errors.Is(err, routing.ErrNotFound) ||
err == routing.ErrNotFound ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 👍 for removing these, it looked like a dead code that could cause hard-to-debug bugs in the futture.

@lidel lidel merged commit 36918f4 into main Feb 28, 2023
@lidel lidel deleted the issue/185 branch February 28, 2023 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

gateway: unify root identifier resolution errors
2 participants