Skip to content

TypeError in sentinel_master on 6.3.0: parse_sentinel_master() got unexpected keyword argument 'return_responses' #3750

@miberl

Description

@miberl

Description

Calling sentinel_master("mymaster") via StrictRedis (alias of Redis) fails on redis-py 6.3.0 with:
TypeError: parse_sentinel_master() got an unexpected keyword argument 'return_responses'

Other Sentinel calls like sentinel_masters() succeed.

Reproducing

Redis-py version: 6.3.0 and 6.4.0.
Python: 3.10
Parser: default & hiredis

Minimal repro:

from redis import StrictRedis
conn = StrictRedis(host='127.0.0.1', port=26379)
conn.sentinel_masters()       # OK
conn.sentinel_master('mymaster')  # TypeError in parser

throws the following error:

Traceback (most recent call last):
  File "/home/user/test-redispy/testbug.py", line 13, in <module>
    print(conn.sentinel_master("mymaster"))
  File "/usr/lib/python3.10/site-packages/redis/commands/sentinel.py", line 31, in sentinel_master
    return self.execute_command(
  File "/usr/lib/python3.10/site-packages/redis/client.py", line 621, in execute_command
    return self._execute_command(*args, **options)
  File "/usr/lib/python3.10/site-packages/redis/client.py", line 632, in _execute_command
    return conn.retry.call_with_retry(
  File "/usr/lib/python3.10/site-packages/redis/retry.py", line 105, in call_with_retry
    return do()
  File "/usr/lib/python3.10/site-packages/redis/client.py", line 633, in <lambda>
    lambda: self._send_command_parse_response(
  File "/usr/lib/python3.10/site-packages/redis/client.py", line 604, in _send_command_parse_response
    return self.parse_response(conn, command_name, **options)
  File "/usr/lib/python3.10/site-packages/redis/client.py", line 664, in parse_response
    return self.response_callbacks[command_name](response, **options)
TypeError: parse_sentinel_master() got an unexpected keyword argument 'return_responses'

Workaround

  • Pin redis to <=6.2.0
  • Or use Sentinel client API:
    from redis.sentinel import Sentinel
    sentinel = Sentinel([("127.0.0.1", 26379)], socket_timeout=1.0)
    print(sentinel.discover_master("mymaster"))

Likely Cause (#3191)

  • sentinel_master calls execute_command with return_responses in **options.
  • parse_response forwards **options to the response callback.
  • The callback for SENTINEL MASTER does not accept return_responses.

Possible fixes

  • Update the callback to accept **options, or
  • Prevent forwarding return_responses to the callback for this command.

Metadata

Metadata

Assignees

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