-
Notifications
You must be signed in to change notification settings - Fork 37
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
Unable to get status from recent version of Velocity server #711
Comments
Discussed on Discord, actual traceback is: Traceback (most recent call last):
File "/app/src/logic/get_status.py", line 54, in get_status
status = await server.async_status(tries=1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/mcstatus/server.py", line 147, in async_status
return await self._retry_async_status(connection, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/mcstatus/utils.py", line 52, in async_wrapper
raise last_exc # type: ignore # (This won't actually be unbound)
^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/mcstatus/utils.py", line 48, in async_wrapper
return await func(*args, **kwargs) # type: ignore # (We know func is awaitable here)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/mcstatus/server.py", line 153, in _retry_async_status
result = await pinger.read_status()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/mcstatus/pinger.py", line 107, in read_status
return JavaStatusResponse.build(raw, latency=(received - start) * 1000)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/mcstatus/status_response.py", line 134, in build
motd=Motd.parse(raw["description"], bedrock=False),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/mcstatus/motd/__init__.py", line 52, in parse
parsed = cls._parse_as_dict(raw, bedrock=bedrock)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/mcstatus/motd/__init__.py", line 137, in _parse_as_dict
parsed_motd.extend(cls._parse_as_dict(element, auto_add=auto_add.copy()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/mcstatus/motd/__init__.py", line 113, in _parse_as_dict
if (color := item.get("color")) is not None:
^^^^^^^^
AttributeError: 'str' object has no attribute 'get' To summarize, we get We can fix it (retry decorator) by removing it or by retrying only the actual logic (not parsing). To be honest, this kind of logic should be on the user, not on us. |
I recall the number of attempts is adjustable. It should be possible to set that to 1 and skip our retry logic. |
Yeah, we could just set the retry amount to 1 by default, but I think we should also make sure the retry logic only runs on the actual connection, and not on parsing logic. However I'm also not opposed to just removing the retry logic entirely. |
We can also set the default value to |
I would prefer setting it to a custom private sentinel object, say like this: from typing import NewType
_SENTINEL_T = NewType("_SENTINEL_T", object)
_SENTINEL = _SENTINEL_T(object())
def some_func(tries: int | _SENTINEL_T = _SENTINEL):
if tries is _SENTINEL:
tries = 1 # or the original 3
else:
deprecation_warn()
... This way no one will leave a There is still the alternative of just setting the default to 1 and making sure we're retrying only the connection logic, instead of completely dropping retries. But yeah, I'm not sure they're worth keeping around. |
I also thought about sentinel, but then I realized that None is just for such cases (as the default value). Anyway, will use sentinel, so it is harder for a user to shoot their own leg. |
Not sure why but connect.2b2t.org specifically does not seem to respond to mcstatus and I'm not getting blocked by their proxy or TCPShield. It seems to be able to get a response from websites like https://mcsrvstat.us, but fails with mcstatus.
The text was updated successfully, but these errors were encountered: