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

When I use the subrouter() method, Methods() only works on the last endpoint, and other than the last endpoint, the rest of the endpoints give a 404 instead of a 405 with the unrelated http method. #751

Open
1 task done
iarsham opened this issue Feb 6, 2024 · 3 comments
Labels

Comments

@iarsham
Copy link

iarsham commented Feb 6, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When I use the subrouter() method, Methods() only works on the last endpoint, and other than the last endpoint, the rest of the endpoints give a 404 instead of a 405 with the unrelated http method.

image

last endpoint :
image

other endpoints:
image

Expected Behavior

No response

Steps To Reproduce

No response

Anything else?

No response

@iarsham iarsham added the bug label Feb 6, 2024
@bhcleek
Copy link

bhcleek commented Feb 27, 2024

Does #748 fix this for you?

@iarsham
Copy link
Author

iarsham commented Mar 7, 2024

Does #748 fix this for you?

no!

@cvermilion
Copy link

This appears to have been broken by #712, which clears a 405 error when a subsequent route matches in any part. The logic here is tricky: the desire is that if

Route 1: POST "/users/{id}".
Route 2: GET "/users/{id}", parameters: "id": "[0-9]+".

are configured, then GET "/users/-2" returns a 404, not a 405, because while it matches route 1 with a method error, it is a "better" match to route 2 with a parameter validation error.

But this logic then also applies to prefix matching in a sub router: the prefix match is the first matcher in the sequence, and a subsequent route that matches the prefix but is otherwise clearly not a match will clear an existing 405. Unfortunately I don't know the mux internals well enough to suggest a fix, but it seems like if the check from #712 is desired, it shouldn't apply to subroute matchers.

arvados-bot pushed a commit to arvados/arvados that referenced this issue Jun 10, 2024
Open issue gorilla/mux#751 (2024-02-06)
causes router to return 404 instead of 405 when the path matches but
method does not.

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants