Skip to content

Commit

Permalink
fix(cache): Fix key_as_string (#3132)
Browse files Browse the repository at this point in the history
  • Loading branch information
sentrivana authored Jun 5, 2024
1 parent c2c7896 commit 8f80dfe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/redis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _safe_decode(key):
except UnicodeDecodeError:
return ""

return key
return str(key)


def _key_as_string(key):
Expand Down
9 changes: 9 additions & 0 deletions tests/integrations/redis/test_redis_cache_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ def test_cache_data(sentry_init, capture_events):
None,
(b"\x00c\x0f\xeaC\xe1L\x1c\xbff\xcb\xcc\xc1\xed\xc6\t",),
),
(
"get",
[123],
None,
(123,),
),
],
)
def test_get_safe_key(method_name, args, kwargs, expected_key):
Expand All @@ -266,6 +272,9 @@ def test_get_safe_key(method_name, args, kwargs, expected_key):
),
(["bla", "blub", "foo"], "bla, blub, foo"),
([uuid.uuid4().bytes], ""),
({"key1": 1, "key2": 2}, "key1, key2"),
(1, "1"),
([1, 2, 3, b"hello"], "1, 2, 3, hello"),
],
)
def test_key_as_string(key, expected_key):
Expand Down

0 comments on commit 8f80dfe

Please sign in to comment.