Skip to content

fix(redact): safely handle non-string inputs (salvage #2369)#2392

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-0fa141a3
Mar 22, 2026
Merged

fix(redact): safely handle non-string inputs (salvage #2369)#2392
teknium1 merged 1 commit intomainfrom
hermes/hermes-0fa141a3

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Summary

Salvage of PR #2369 by @aydnOktay. Cherry-picked cleanly onto current main.

redact_sensitive_text() now handles non-string inputs defensively:

  • Returns None early for None input (explicit check instead of relying on truthiness)
  • Coerces other non-string values (int, dict, etc.) to str before applying regex patterns
  • Prevents TypeError crashes when non-string values flow through logging/tool-output paths

Two new tests: int coercion and dict coercion with redaction.

Tests: 31/31 redact tests passing.

Credit: @aydnOktay (original author, commit authorship preserved).

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.
@teknium1 teknium1 merged commit 1d28b46 into main Mar 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants