mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix(redact): safely handle non-string inputs
redact_sensitive_text() now returns early for None and coerces other non-string values to str before applying regex-based redaction, preventing TypeErrors in logging/tool-output paths. Cherry-picked from PR #2369 by aydnOktay.
This commit is contained in:
parent
52dd479214
commit
40c9a13476
2 changed files with 11 additions and 0 deletions
|
|
@ -100,6 +100,10 @@ def redact_sensitive_text(text: str) -> str:
|
|||
Safe to call on any string -- non-matching text passes through unchanged.
|
||||
Disabled when security.redact_secrets is false in config.yaml.
|
||||
"""
|
||||
if text is None:
|
||||
return None
|
||||
if not isinstance(text, str):
|
||||
text = str(text)
|
||||
if not text:
|
||||
return text
|
||||
if os.getenv("HERMES_REDACT_SECRETS", "").lower() in ("0", "false", "no", "off"):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue