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

Return correct unknown path/method response #43

Closed
babolivier opened this issue Dec 2, 2022 · 3 comments · Fixed by #55
Closed

Return correct unknown path/method response #43

babolivier opened this issue Dec 2, 2022 · 3 comments · Fixed by #55
Assignees

Comments

@babolivier
Copy link
Contributor

If a method/path pair is unknown, aiohttp simply sends a response which body is a text representation of the error (e.g. 405: Method Not Allowed). It does so by falling back onto default handlers that raise an HTTPException. We can write a very simple middleware that catches those and turns them into response with Matrix-compatible error bodies.

@DMRobertson
Copy link
Contributor

PC notes in https://github.com/vector-im/matrix-content-scanner-python/pull/49/files#r1406110984 that we should return M_UNRECOGNISED if a (method, pair) path is unknown.

@clokep clokep changed the title Change default response format Return correct unknown path/method response Nov 27, 2023
@clokep
Copy link
Contributor

clokep commented Nov 28, 2023

I think the way to do this is to add a middleware which converts HTTPNotFound and HttpMethodNotAllowed errors to the proper JSON responses.

@clokep
Copy link
Contributor

clokep commented Nov 29, 2023

Was kind of easy once I figured out aiohttp, see #55.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants