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

Fix username logging on 500 responses. #754

Merged
merged 7 commits into from
Jun 1, 2024

Conversation

danielballan
Copy link
Member

@danielballan danielballan commented May 31, 2024

A bug causes the server to send no response, such that the client raised:

RemoteProtocolError: Server disconnected without sending a response.

instead of returning 500 response. This was a regression introduced in #750.

Needs test.

Closes #753

Checklist

  • Add a Changelog entry
  • Add the ticket number which this PR closes to the comment section

A bug causes the server to send no response, such that the client
raised:

```
RemoteProtocolError: Server disconnected without sending a response.
```

instead of returning 500 response. This was a regression
introduced in bluesky#750.

Needs test.

Closes bluesky#750
@danielballan
Copy link
Member Author

The unit test added in 485672a, when run on the main branch, reproduces the error:

E           httpx.RemoteProtocolError: Server disconnected without sending a response.

../../../micromamba/envs/py311/lib/python3.11/site-packages/httpx/_transports/default.py:83: RemoteProtocolError

@danielballan danielballan marked this pull request as ready for review June 1, 2024 12:08
@danielballan
Copy link
Member Author

Confirmed again that introducing a bug...

diff --git a/tiled/server/principal_log_filter.py b/tiled/server/principal_log_filter.py
index cf5a534f..59dd0e86 100644
--- a/tiled/server/principal_log_filter.py
+++ b/tiled/server/principal_log_filter.py
@@ -9,6 +9,7 @@ class PrincipalFilter(Filter):
 
     def filter(self, record: LogRecord) -> bool:
         principal = current_principal.get(None)
+        raise Exception
         if principal is None:
             # This will only occur if an uncaught exception was raised in the
             # server before the authentication code ran. This will always be

...fails the new unit test:

FAILED tiled/_tests/test_server.py::test_500_response - httpx.RemoteProtocolError: Server disconnected without sending a response.

@danielballan
Copy link
Member Author

Self-merging as a hotfix.

@danielballan danielballan merged commit 3c19b6d into bluesky:main Jun 1, 2024
9 checks passed
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 this pull request may close these issues.

Fix RemoteProtocolError: Server disconnected without sending a response.
1 participant