Skip to content

Commit

Permalink
fix(weave): don't check non-string dict keys for sensitive key redaction
Browse files Browse the repository at this point in the history
  • Loading branch information
jamie-rasmussen committed Jan 14, 2025
1 parent 1701e88 commit 7aaaeaa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions weave/trace/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def dictify(
elif isinstance(obj, dict):
dict_result = {}
for k, v in obj.items():
if should_redact(k):
if isinstance(k, str) and should_redact(k):
dict_result[k] = REDACTED_VALUE
else:
dict_result[k] = dictify(v, maxdepth, depth + 1, seen)
Expand All @@ -160,7 +160,7 @@ def dictify(
if isinstance(as_dict, dict):
to_dict_result = {}
for k, v in as_dict.items():
if should_redact(k):
if isinstance(k, str) and should_redact(k):
to_dict_result[k] = REDACTED_VALUE
elif maxdepth == 0 or depth < maxdepth:
to_dict_result[k] = dictify(v, maxdepth, depth + 1)
Expand Down
2 changes: 1 addition & 1 deletion weave/trace/weave_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1711,7 +1711,7 @@ def redact_sensitive_keys(obj: Any) -> Any:
if isinstance(obj, dict):
dict_res = {}
for k, v in obj.items():
if should_redact(k):
if isinstance(k, str) and should_redact(k):
dict_res[k] = REDACTED_VALUE
else:
dict_res[k] = redact_sensitive_keys(v)
Expand Down

0 comments on commit 7aaaeaa

Please sign in to comment.