Skip to content

The agent that grows with you

fix(debug): keep a scheme before an already-redacted header value

kshitijk4poorb9e34b1284cc
diff --git a/hermes_cli/debug_redaction.py b/hermes_cli/debug_redaction.py
index f1a3d2ace94..a7c984514c5 100644
--- a/hermes_cli/debug_redaction.py
+++ b/hermes_cli/debug_redaction.py
@@ -53,7 +53,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+)?(?!\[REDACTED\])[^\s,}\]]+)",
+ r"(?P<value>(?>(?:(?:Bearer|Basic|Digest)\s+)?)(?!\[REDACTED\])[^\s,}\]]+)",
re.IGNORECASE,
)
@@ -87,7 +87,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+)?(?!\[REDACTED\])(?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.py
index 7c3c8b83ac0..c7399af8ab4 100644
--- a/tests/tui_gateway/test_diagnostics_share_nous.py
+++ b/tests/tui_gateway/test_diagnostics_share_nous.py
@@ -177,6 +177,7 @@ def test_redacted_support_egress_scrubs_structured_values_and_errors(
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']}")
+ + " --header X-API-Key Basic [REDACTED]"
)
monkeypatch.setattr(du, "share_to_nous", _fail)
@@ -185,6 +186,7 @@ def test_redacted_support_egress_scrubs_structured_values_and_errors(
assert canaries["error"] not in failure["error"]
assert canaries["header"] not in failure["error"]
assert "[REDACTED]]" not in failure["error"]
+ assert failure["error"].endswith(" --header X-API-Key Basic [REDACTED]")
def test_share_nous_linkless_success_is_a_failure(monkeypatch):