Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Version 1.0.0 #2384
base: master
Are you sure you want to change the base?
Version 1.0.0 #2384
Changes from all commits
7b62e9d
4d436f6
d1d388f
707cb38
fa739e1
3d09c8b
6edecb7
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
We need to remove ExceptionMiddleware from here. And maybe delete that file as well.
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.
Where should we register the
starlette.exception_handlers
now?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.
Sorry, I guess we need to get rid of is this part:
starlette/starlette/middleware/exceptions.py
Line 62 in 966f0fc
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.
Ah! Just to confirm: you mean that the
ExceptionMiddleware
should just register theexception_handlers
in the scope, but thewrap_app_handling_exceptions
should NOT be called there, only on the other places we have them (request_response
andwebsocket_session
). Correct?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.
Yep!
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.
I cannot come up with a solution for this, FYI.
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.
@adriangb how do you want to proceed here? We talked in PyCon US a bit, but I don't recall how we left this.
This is the only blocker for 1.0.
The only thing is that I don't want to add any breaking change.
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.
If you want to do this without any breaking change we can just leave
ExceptionMiddleware
where it is and ignore this thread.But conceptually I think the thing is that:
HTTPException
's but I think the API should essentially be an ASGI appHTTPException | int, Scope, Receive, Send
or something like that. But that would be a breaking change. Otherwise I fear we're going to get bugs like "I wanted to catch the404
HTTPException and log the request body but when I called.body()
I got aStreamConsumed
error".To do that we'd have to replace
ExceptionMiddleware
withAppExceptionMiddleware
or something like that with the new API and have two different arguments toStarlette
for each type of exception handler.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.
Leaving the pure ASGI realm, I have a minimalistic and effective design. https://github.com/abersheeran/baize/blob/master/baize/asgi/shortcut.py#L59
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.
Very nice :)