The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(debug): make the support scrub idempotent on [REDACTED] values
kshitijk4poor612518bc7ef1
diff --git a/hermes_cli/debug.py b/hermes_cli/debug.pyindex 3417cbeae96..d98cecc0d8c 100644--- a/hermes_cli/debug.py+++ b/hermes_cli/debug.py@@ -208,7 +208,7 @@ def upload_to_pastebin(content: str, expiry_days: int = 1) -> str:try:return upload()except Exception as exc:- errors.append(f"{service}: {redact_debug_support_error(exc)}")+ errors.append(f"{service}: {exc}") # every caller scrubs the RuntimeErrorraise RuntimeError("Failed to upload to any paste service:\n " + "\n ".join(errors))diff --git a/hermes_cli/debug_redaction.py b/hermes_cli/debug_redaction.pyindex 2b26b974d0b..9285fcd2bcc 100644--- a/hermes_cli/debug_redaction.py+++ b/hermes_cli/debug_redaction.py@@ -57,7 +57,7 @@ _QUOTED_HEADER_RE = re.compile()_BARE_HEADER_RE = re.compile(rf"(?P<prefix>\b(?:{_HEADER_NAME_PATTERN})\b\s*[:=]\s*)"- r"(?P<value>(?:(?:Bearer|Basic|Digest)\s+)?[^\s,}\]]+)",+ r"(?P<value>(?>(?:Bearer|Basic|Digest)\s+)?(?!\[REDACTED\])[^\s,}\]]+)",re.IGNORECASE,)@@ -74,12 +74,12 @@ _QUOTED_ARGV_RE = re.compile()_ARG_EQUALS_RE = re.compile(rf"(?P<flag>{_SECRET_ARG_FLAG})(?P<sep>\s*=\s*)"- r"(?P<quote>['\"]?)(?P<value>[^\s,}\]'\"]+)(?P=quote)",+ r"(?P<quote>['\"]?)(?!\[REDACTED\])(?P<value>[^\s,}\]'\"]+)(?P=quote)",re.IGNORECASE,)_ARG_OPERAND_RE = re.compile(rf"(?P<flag>{_SECRET_ARG_FLAG})(?P<sep>\s+)"- r"(?P<quote>['\"]?)(?P<value>[^\s,}\]'\"]+)(?P=quote)",+ r"(?P<quote>['\"]?)(?!\[REDACTED\])(?P<value>[^\s,}\]'\"]+)(?P=quote)",re.IGNORECASE,)_HEADER_ARGV_RE = re.compile(@@ -91,7 +91,7 @@ _HEADER_ARGV_RE = re.compile()_PLAIN_HEADER_ARG_RE = re.compile(rf"(?P<prefix>--header\s+(?:{_HEADER_NAME_PATTERN})\s+)"- r"(?:(?:Bearer|Basic|Digest)\s+)?(?P<value>[^\s,}\]]+)",+ r"(?>(?:Bearer|Basic|Digest)\s+)?(?!\[REDACTED\])(?P<value>[^\s,}\]]+)",re.IGNORECASE,)_SUPPORT_BEARER_RE = re.compile(diff --git a/tests/tui_gateway/test_diagnostics_share_nous.py b/tests/tui_gateway/test_diagnostics_share_nous.pyindex 4ffb37eb828..9f9edcbae8d 100644--- a/tests/tui_gateway/test_diagnostics_share_nous.py+++ b/tests/tui_gateway/test_diagnostics_share_nous.py@@ -164,9 +164,13 @@ def test_redacted_support_egress_scrubs_structured_values_and_errors(import hermes_cli.diagnostics_upload as dudef _fail(_blob: bytes) -> dict:+ # The tail is already scrubbed (a wrapped inner error); re-scrubbing it+ # must be idempotent, not turn ``[REDACTED]`` into ``[REDACTED]]``.raise RuntimeError("PUT https://upload.invalid/?X-Amz-Security-Token="- f"{canaries['error']} headers={{'X-API-Key': '{canaries['header']}'}}"+ f"{canaries['error']} headers={{'X-API-Key': '{canaries['header']}'}} "+ + real_redact(f"cookie={canaries['error']}; --api-key {canaries['error']} "+ f"--header X-API-Key {canaries['error']}"))monkeypatch.setattr(du, "share_to_nous", _fail)@@ -174,6 +178,7 @@ def test_redacted_support_egress_scrubs_structured_values_and_errors(assert failure["ok"] is Falseassert canaries["error"] not in failure["error"]assert canaries["header"] not in failure["error"]+ assert "[REDACTED]]" not in failure["error"]def test_share_nous_linkless_success_is_a_failure(monkeypatch):