happyleavesaoc/aoc-mgz

RuntimeError: invalid mgz file: unsane min -1 and max -1

Closed this issue · 4 comments

When parsing DE match 41599594 the following error occurs. Note that the match is only 25 seconds long, so I am not sure whether this really needs to be fixed. Maybe the recording is just broken?

Traceback (most recent call last):
File \"/opt/pypy/site-packages/mgz/summary/__init__.py\", line 72, in __init__
    self._header = mgz.header.parse_stream(self._handle)
File \"/opt/pypy/site-packages/construct/core.py\", line 171, in parse_stream
    return self._parse(stream, context2, \"(parsing)\")
File \"/opt/pypy/site-packages/construct/core.py\", line 867, in _parse
    subobj = sc._parse(stream, context, path)
File \"/opt/pypy/site-packages/construct/core.py\", line 295, in _parse
    return self.subcon._parse(stream, context, path)
File \"/opt/pypy/site-packages/construct/core.py\", line 867, in _parse
    subobj = sc._parse(stream, context, path)
File \"/opt/pypy/site-packages/construct/core.py\", line 295, in _parse
    return self.subcon._parse(stream, context, path)
File \"/opt/pypy/site-packages/mgz/util.py\", line 57, in _parse
    return self.subcon._parse(new_stream, context, path)
File \"/opt/pypy/site-packages/construct/core.py\", line 357, in _parse
    return self.subcon.parse(data, context)
File \"/opt/pypy/site-packages/construct/core.py\", line 158, in parse
    return self.parse_stream(BytesIO(data), context, **kw)
File \"/opt/pypy/site-packages/construct/core.py\", line 171, in parse_stream
    return self._parse(stream, context2, \"(parsing)\")
File \"/opt/pypy/site-packages/construct/core.py\", line 867, in _parse
    subobj = sc._parse(stream, context, path)
File \"/opt/pypy/site-packages/construct/core.py\", line 1036, in _parse
    raise RangeError(\"unsane min %s and max %s\" % (min, max))
construct.core.RangeError: unsane min -1 and max -1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File \"process.py\", line 42, in <module>
    summary = mgz.summary.Summary(handle, None)
File \"/opt/pypy/site-packages/mgz/summary/__init__.py\", line 84, in __init__
    raise RuntimeError(\"invalid mgz file: {}\".format(e))
RuntimeError: invalid mgz file: unsane min -1 and max -1

I've replicated the error. The rec appears valid since it loads in DE.

Skazu commented

I think this issue was caused because there was an ai involved in the match.

Can you try again parsing the match and verify if the error still exists? The latest pull request should have solved it, so please make sure to install aoc-mgz from latest master.

I am getting the following error now for AgeIIDE_Replay_41599731.zip

ValueError: 130 is not a valid Action

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/denniskeil/Projects/aoc-mgz/mgz/summary/__init__.py", line 81, in __init__
    self._process_body()
  File "/Users/denniskeil/Projects/aoc-mgz/mgz/summary/__init__.py", line 103, in _process_body
    operation, payload = fast.operation(self._handle)
  File "/Users/denniskeil/Projects/aoc-mgz/mgz/fast.py", line 262, in operation
    return op_type, action(data)
  File "/Users/denniskeil/Projects/aoc-mgz/mgz/fast.py", line 204, in action
    action_type = Action(action_id)
  File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/enum.py", line 309, in __call__
    return cls.__new__(cls, value)
  File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/enum.py", line 600, in __new__
    raise exc
  File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/enum.py", line 584, in __new__
    result = cls._missing_(value)
  File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/enum.py", line 613, in _missing_
    raise ValueError("%r is not a valid %s" % (value, cls.__name__))
ValueError: 130 is not a valid Action

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 58, in <module>
    summary = Summary(data)
  File "/Users/denniskeil/Projects/aoc-mgz/mgz/summary/__init__.py", line 84, in __init__
    raise RuntimeError("invalid mgz file: {}".format(e))
RuntimeError: invalid mgz file: 130 is not a valid Action

Fixed in 632352c. We detect and register but don't parse these yet. If we look at the rec file maybe we'll see what these new DE actions are.

ID    Name                     Count
----  ---------------------  -------
0x82  DE_UNKNOWN_130            4885
0x6d  DE_UNKNOWN_109             353
0x25  DE_UNKNOWN_37              305
0x23  DE_UNKNOWN_35               95
0x29  DE_UNKNOWN_41               38
0x27  DE_UNKNOWN_39                3