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
Provide a reason when route cannot be found. #2014
Conversation
+1 on this, might be less noisy to just print the path rather than the whole string in the reason though - open to suggestions |
Thanks @0xTim. I don't mind either way. I'm happy to change if the reviewer prefers. BTW, any idea why circle ci is stuck on one of the tests? It's been pending for days... |
@maciejtrybilo at a guess it's waiting for a review approval to be kicked off |
The compatibility suite needs to be run manually. |
@0xTim Updated to only print the path. |
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. CC @tanner0101
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.
Hmm I'm not sure I understand the reasoning behind this. As a user, why would I need to see the path that I just typed in to request the resource?
I could see this being useful in logs, but I'm not sure about being returned to the user.
@tanner0101 its to bring parity with Vapor 2 and for logs as well. Especially in a browser there are lots of 404s that confuse people (mainly favicons and Apple touch icons) so it would be good to surface those with the 404s. |
@0xTim Thanks! Do you have the credentials to rerun the failed test? It looks like it timed out. |
@maciejtrybilo I do not unfortunately (although I think I should do @tanner0101 ?) Anyway, I don't think rerunning would help, it looks like the error is a package dependency issue with that package in the compatability suite, though it was last run a while ago so might work now. |
@tanner0101 bump |
This is much more useful for logs than it is the browser. Hosting on AWS you just see abort 404 in cloud watch so you get nothing. |
IIRC by adding it to |
I still don't fully understand the benefit behind this. In the browser, the console shows the request for a given error which includes the path. |
@tanner0101 I can provide some context here. on AWS, this is all you get to see when there is a 404. I wrote my own middleware to solve this, but it would be nice to have OOB |
@kylebrowning ah okay, that context helps a lot. I agree that could be improved. That should be fixed by improving ErrorMiddleware which has access to the incoming request and can get the path that way. |
@tanner0101 I agree with that approach, that's why I copied ErrorMiddleware and just modified it. |
@tanner0101 do you have permissions to kick the CI or shall I just merge it? |
I'll see if I can give the CI a kick |
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.
@0xTim CI is being weird, but builds are green, so it's fine by me.
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.
From my previous comment, I think this should be fixed by logging the path from either ErrorMiddleware
or in the ApplicationResponder
. I don't think putting the path in the reason make sense.
That should be fixed by improving ErrorMiddleware which has access to the incoming request and can get the path that way.
@maciejtrybilo do you want to do the update? |
@0xTim Yep, I should have some time soon. |
Closing and opening a new PR instead following @tanner0101 suggestions: #2170 |
Currently when the router cannot find an endpoint for a requested resource the reason in the response is "Not Found". This PR makes the reason more specific which allows the 404 to be easier do diagnose.
Checklist
///
.