Skip to content

python-valve is reporting an error when there is none #83

@andykais

Description

@andykais
  • Python-valve Version(s): python-valve==0.2.1
  • Python Version(s): 3.6.8
  • Operating System(s)/Platform(s): macos
  • Game Server(s) and Version(s): a2s (I cannot share more here)

Hi, when I run the following snippet,

def query_server(host, port):
  sqp_address = (host, port + 1)
  server = valve.source.a2s.ServerQuerier(sqp_address)
  info = server.info()
  rules = server.rules()

server.info() succeeds and returns proper data, but server.rules() throws the exception

Traceback (most recent call last):
  File "/Users/andrew/.virtualenvs/python-valve-a2s/lib/python3.6/site-packages/valve/source/messages.py", line 91, in validate
    raise ValueError
ValueError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "query_server.py", line 28, in <module>
    info_dump = query_server(host, port)
  File "query_server.py", line 20, in query_server
    rules = server.rules()
  File "/Users/andrew/.virtualenvs/python-valve-a2s/lib/python3.6/site-packages/valve/source/a2s.py", line 226, in rules
    challenge = messages.GetChallengeResponse.decode(self.get_response())
  File "/Users/andrew/.virtualenvs/python-valve-a2s/lib/python3.6/site-packages/valve/source/messages.py", line 415, in decode
    values[field.name], buffer = field.decode(buffer, values)
  File "/Users/andrew/.virtualenvs/python-valve-a2s/lib/python3.6/site-packages/valve/source/messages.py", line 41, in needs_buffer
    return func(self, buffer, *args, **kwargs)
  File "/Users/andrew/.virtualenvs/python-valve-a2s/lib/python3.6/site-packages/valve/source/messages.py", line 131, in decode
    struct.unpack(self.format, field_data)[0]), left_overs)
  File "/Users/andrew/.virtualenvs/python-valve-a2s/lib/python3.6/site-packages/valve/source/messages.py", line 95, in validate
    value, self.name))
valve.source.messages.BrokenMessageError: Invalid value (69) for field 'response_type'

strangely, the same server responds fine using qstat and if I change the line on

ByteField("response_type", validators=[lambda x: x == 0x41]),

to be

        ByteField("response_type", validators=[lambda x: x == 0x41 or x == 69]),

then the rules field returns proper data. I don't know if this is a happy accident that I am getting proper data back, or if GetChallengeResponse should actually accept a wider range of inputs. Unfortunately I cannot share the server address, but hopefully this is enough to go off of

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions