Skip to content

xinfo_stream IndexError: list index out of range #3065

@yycoolsam

Description

@yycoolsam

Version: redis-py version 5.0.1, Redis: 6.0(23.8.1.3)

Platform: Python3.8.10 on WIN10
Description: redis-py fails to parse xinfo_stream replies if the stream is emptied by XTRIM command.

For example,

  File "E:\Program\qhdata_etl\src\venv\lib\site-packages\redis\client.py", line 513, in _send_command_parse_response
    return self.parse_response(conn, command_name, **options)
  File "E:\Program\qhdata_etl\src\venv\lib\site-packages\redis\client.py", line 563, in parse_response
    return self.response_callbacks[command_name](response, **options)
  File "E:\Program\qhdata_etl\src\venv\lib\site-packages\redis\_parsers\helpers.py", line 272, in parse_xinfo_stream
    data["first-entry"] = (first[0], pairs_to_dict(first[1]))
IndexError: list index out of range

After inspecting the source code, I believe this issue is platform-independent. parse_xinfo_stream function in client.py assumes that first-entry and last-entry in the reply are valid enties. However, after XTRIM STREAM MAXLEN 0, those two fields will become [None], which leads to the parse error.

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