Skip to content

xinfo_stream IndexError: list index out of range #3065

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

Closed
yycoolsam opened this issue Dec 5, 2023 · 0 comments · Fixed by #3282
Closed

xinfo_stream IndexError: list index out of range #3065

yycoolsam opened this issue Dec 5, 2023 · 0 comments · Fixed by #3282

Comments

@yycoolsam
Copy link

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.

@yycoolsam yycoolsam changed the title xinfo_stream xinfo_stream IndexError: list index out of range Dec 6, 2023
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 a pull request may close this issue.

1 participant