Skip to content

fix: handle both bytes and string Redis keys when decode_responses=True #34

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bsbodden
Copy link
Contributor

Resolves issue #24 where Redis key decoding would fail when a client
was configured with decode_responses=True. Adds a new safely_decode
utility function that handles both bytes and string keys.

  Resolves issue #24 where Redis key decoding would fail when a client
  was configured with decode_responses=True. Adds a new `safely_decode`
  utility function that handles both bytes and string keys.
@bsbodden bsbodden requested review from tylerhutcherson and removed request for tylerhutcherson April 30, 2025 22:05
@bsbodden
Copy link
Contributor Author

@tylerhutcherson an experimental PR to test the bytes/string encoding issue. Some CI issues on this one, will let it sit and handle it before the release (or push it for the next one, it's not critical)

@@ -81,3 +83,22 @@ def from_storage_safe_id(value: str) -> str:
return ""
else:
return value


def safely_decode(key: Union[bytes, str]) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bsbodden good news -- https://github.com/redis/redis-vl-python/blob/9f22a9ad4c2166af6462b007833b456448714dd9/redisvl/redis/utils.py#L20
We have this util already in redisvl that is tested and should work for this use case :)

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 this pull request may close these issues.

2 participants