Skip to content

running dump() fails when decode_responses=True #1254

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
brianmaissy opened this issue Dec 18, 2019 · 3 comments · Fixed by #1731
Closed

running dump() fails when decode_responses=True #1254

brianmaissy opened this issue Dec 18, 2019 · 3 comments · Fixed by #1731

Comments

@brianmaissy
Copy link

redis-py 3.3.6
python 3.6.9
Ubuntu 18.04
redis 4.0.9

I have a Redis instance that I created with decode_responses=True. When I run .dump(key) the decoder fails to decode the bytes response, which makes sense, because it isn't unicode.

  File "/home/brian/.local/lib/python3.6/site-packages/redis/client.py", line 3677, in execute
    return execute(conn, stack, raise_on_error)
  File "/home/brian/.local/lib/python3.6/site-packages/redis/client.py", line 3570, in _execute_transaction
    response = self.parse_response(connection, '_')
  File "/home/brian/.local/lib/python3.6/site-packages/redis/client.py", line 3636, in parse_response
    self, connection, command_name, **options)
  File "/home/brian/.local/lib/python3.6/site-packages/redis/client.py", line 853, in parse_response
    response = connection.read_response()
  File "/home/brian/.local/lib/python3.6/site-packages/redis/connection.py", line 687, in read_response
    response = self._parser.read_response()
  File "/home/brian/.local/lib/python3.6/site-packages/redis/connection.py", line 442, in read_response
    response = self._reader.gets()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 1: invalid continuation byte
@Stan1sl0s
Copy link

Stan1sl0s commented Jan 7, 2020

Hello,

I have an issue too on decode_responses. UTF8 decoding for sentinel part seems not working :

self.master = self.sentinel.master_for(redis_sentinels_master, socket_timeout=socket_db_timeout, db=db,  encoding=u'utf-8', decode_responses=True)
print(self.master.get(myKey))
b'xyz'

@vcaboara
Copy link

I don't know why, but this seems to have broken for me as well.

chayim added a commit that referenced this issue Nov 21, 2021
Some commands (i.e DUMP) should never have their response decoded, as they return binaries, not encoded blobs

fixes #1254
@brianmaissy
Copy link
Author

@chayim could it be that the fix in #1731 doesn't cover the use of non-decodable commands in a pipeline? (see the original stack trace above). In _execute_transaction() it looks like the options aren't passed through to parse_response()

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.

3 participants