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

Nicer error handling when there is no content #204

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ChillerDragon
Copy link

204 No Content is indicating success
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204

The same check already happend in the error callback but that one does not seem to get hit.

Now the error also contains the url that was expected to return content. So the user knows where to start debugging.

I am currently getting back no content half of the time for this url https://sessionserver.mojang.com/session/minecraft/hasJoined?username=xxx&serverId=xxx&ip=127.0.0.1

and then it crashes with the following error:

Traceback (most recent call last):
  File "/home/chiller/Desktop/git/2bored2wait-quarry/venv/lib/python3.10/site-packages/twisted/internet/defer.py", line 1078, in _runCallbacks
    current.result = callback(  # type: ignore[misc]
  File "/home/chiller/Desktop/git/quarry/quarry/net/http.py", line 49, in _callback2
    d0.callback(None)
  File "/home/chiller/Desktop/git/2bored2wait-quarry/venv/lib/python3.10/site-packages/twisted/internet/defer.py", line 877, in callback
    self._startRunCallbacks(result)
  File "/home/chiller/Desktop/git/2bored2wait-quarry/venv/lib/python3.10/site-packages/twisted/internet/defer.py", line 984, in _startRunCallbacks
    self._runCallbacks()
--- <exception caught here> ---
  File "/home/chiller/Desktop/git/2bored2wait-quarry/venv/lib/python3.10/site-packages/twisted/internet/defer.py", line 1078, in _runCallbacks
    current.result = callback(  # type: ignore[misc]
  File "/home/chiller/Desktop/git/quarry/quarry/net/server.py", line 128, in auth_ok
    self.uuid = UUID.from_hex(data['id'])
builtins.TypeError: 'NoneType' object is not subscriptable

Now it prints the following helpful error message:

Auth failed: No Content: No content was returned by the server for the url b'https://sessionserver.mojang.com/session/minecraft/hasJoined?username=xxx&serverId=xxx&ip=127.0.0.1

Before

Using the proxy chat example with online auth patched in it would occasionally break for me.
Then it crashes on NoneType in the log and the vanilla minecraft client gets stuck in the "Encrypting..." screen.

image

After

Now it shows a clear error what went wrong it the log without crashing. And the end user also sees the information.

new_error_in_proxy

204 No Content is indicating success
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204

The same check already happend in the error callback but that one
does not seem to get hit.

Now the error also contains the url that was expected to return content.
So the user knows where to start debugging.

I am currently getting back no content half of the time for this url
https://sessionserver.mojang.com/session/minecraft/hasJoined?username=xxx&serverId=xxx&ip=127.0.0.1

and then it crashes with the following error:

```
Traceback (most recent call last):
  File "/home/chiller/Desktop/git/2bored2wait-quarry/venv/lib/python3.10/site-packages/twisted/internet/defer.py", line 1078, in _runCallbacks
    current.result = callback(  # type: ignore[misc]
  File "/home/chiller/Desktop/git/quarry/quarry/net/http.py", line 49, in _callback2
    d0.callback(None)
  File "/home/chiller/Desktop/git/2bored2wait-quarry/venv/lib/python3.10/site-packages/twisted/internet/defer.py", line 877, in callback
    self._startRunCallbacks(result)
  File "/home/chiller/Desktop/git/2bored2wait-quarry/venv/lib/python3.10/site-packages/twisted/internet/defer.py", line 984, in _startRunCallbacks
    self._runCallbacks()
--- <exception caught here> ---
  File "/home/chiller/Desktop/git/2bored2wait-quarry/venv/lib/python3.10/site-packages/twisted/internet/defer.py", line 1078, in _runCallbacks
    current.result = callback(  # type: ignore[misc]
  File "/home/chiller/Desktop/git/quarry/quarry/net/server.py", line 128, in auth_ok
    self.uuid = UUID.from_hex(data['id'])
builtins.TypeError: 'NoneType' object is not subscriptable
```

Now it prints the following helpful error message:

```
Auth failed: No Content: No content was returned by the server for the url b'https://sessionserver.mojang.com/session/minecraft/hasJoined?username=xxx&serverId=xxx&ip=127.0.0.1
```
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.

1 participant