Skip to content

Commit 8f80dfe

Browse files
authored
fix(cache): Fix key_as_string (#3132)
1 parent c2c7896 commit 8f80dfe

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

sentry_sdk/integrations/redis/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def _safe_decode(key):
5252
except UnicodeDecodeError:
5353
return ""
5454

55-
return key
55+
return str(key)
5656

5757

5858
def _key_as_string(key):

tests/integrations/redis/test_redis_cache_module.py

+9
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,12 @@ def test_cache_data(sentry_init, capture_events):
244244
None,
245245
(b"\x00c\x0f\xeaC\xe1L\x1c\xbff\xcb\xcc\xc1\xed\xc6\t",),
246246
),
247+
(
248+
"get",
249+
[123],
250+
None,
251+
(123,),
252+
),
247253
],
248254
)
249255
def test_get_safe_key(method_name, args, kwargs, expected_key):
@@ -266,6 +272,9 @@ def test_get_safe_key(method_name, args, kwargs, expected_key):
266272
),
267273
(["bla", "blub", "foo"], "bla, blub, foo"),
268274
([uuid.uuid4().bytes], ""),
275+
({"key1": 1, "key2": 2}, "key1, key2"),
276+
(1, "1"),
277+
([1, 2, 3, b"hello"], "1, 2, 3, hello"),
269278
],
270279
)
271280
def test_key_as_string(key, expected_key):

0 commit comments

Comments
 (0)