-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
panic with HandleMethodNotAllowed and route corner case #3459
Comments
kristiansvalland
added a commit
to kristiansvalland/gin
that referenced
this issue
Jan 3, 2023
…te fix. gin-gonic#3459 Signed-off-by: Kristian Svalland <kristian.svalland@gmail.com>
kristiansvalland
added a commit
to kristiansvalland/gin
that referenced
this issue
Jan 3, 2023
Also add test to validate fix. fixes gin-gonic#3459 Signed-off-by: Kristian Svalland <kristian.svalland@gmail.com>
kristiansvalland
added a commit
to kristiansvalland/gin
that referenced
this issue
Jan 4, 2023
Also add test to validate fix. fixes gin-gonic#3459 Signed-off-by: Kristian Svalland <kristian.svalland@gmail.com>
kristiansvalland
added a commit
to kristiansvalland/gin
that referenced
this issue
Jan 4, 2023
Also add test to validate fix. fixes gin-gonic#3459 Signed-off-by: Kristian Svalland <kristian.svalland@gmail.com>
appleboy
pushed a commit
that referenced
this issue
Jan 7, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Setting
HandleMethodNotAllowed
on the engine and configuring the routes in a intricate way, gin panics when a certain request is sent. See details below on how to reproduce.How to reproduce
Now, make a
GET
on "localhost:8080/base/v1/user/groups", in which case gin panics.I must admit that the above setup is a bit off, with how ".../:id/devices" and ".../user/:id/groups" is overlapping somewhat, but I still do not expect a panic. If the setup of the routes truly is wrong, then I would expect a panic to happen earlier, either at
r.GET()
orr.Run()
.I've also tried to delete some of the routes to minimize the example, but it seems that all lines are needed for this to fail, which further emphasize that this is a corner case.
Expectations
Actual result
With the following log message from the gin app:
Environment
Suggested fix
As hinted by in the backtrace, the panic occurs in
tree.go#L637
, specifically here (with commentary and suggested fix commented):Note: The above logic happens three places in
tree.go
, so they should probably also be fixed at the same time.Capacity for working on this
I have already created a test and fix for this issue, which I will create a PR for promptly.
The text was updated successfully, but these errors were encountered: