Skip to content

The agent that grows with you

refactor(debug): drop the dead header set and the support-scrub aliases

kshitijk4poore76855f3b92e
diff --git a/gateway/slash_commands.py b/gateway/slash_commands.py
index b55a6b9031a..c9d377d9ac6 100644
--- a/gateway/slash_commands.py
+++ b/gateway/slash_commands.py
@@ -1216,7 +1216,7 @@ class GatewaySlashCommandsMixin(
from hermes_cli.debug import (_GATEWAY_PRIVACY_NOTICE, _best_effort_sweep_expired_pastes,
_capture_dump, _is_dpaste_url, _schedule_auto_delete,
collect_debug_report, upload_to_pastebin)
- from hermes_cli.debug_redaction import redact_debug_support_error
+ from hermes_cli.debug_redaction import redact_debug_support_text
def _collect_and_upload(): # blocking I/O (dump capture, log reads, uploads) -> thread
_best_effort_sweep_expired_pastes()
@@ -1224,7 +1224,7 @@ class GatewaySlashCommandsMixin(
try:
urls = {t("gateway.debug.report_label"): upload_to_pastebin(report)}
except Exception as exc:
- return t("gateway.debug.upload_failed", error=redact_debug_support_error(exc))
+ return t("gateway.debug.upload_failed", error=redact_debug_support_text(exc))
_schedule_auto_delete(list(urls.values())) # paste.rs only; dpaste.com has no delete
label_width = max(len(k) for k in urls)
# The 6-hour line is only true for paste.rs; the privacy notice above already states
diff --git a/hermes_cli/debug.py b/hermes_cli/debug.py
index d98cecc0d8c..219c1f99edc 100644
--- a/hermes_cli/debug.py
+++ b/hermes_cli/debug.py
@@ -15,10 +15,7 @@ from types import SimpleNamespace
from typing import Optional
from hermes_constants import get_hermes_home
-from hermes_cli.debug_redaction import (
- redact_debug_support_error,
- redact_debug_support_text,
-)
+from hermes_cli.debug_redaction import redact_debug_support_text
from utils import atomic_json_write
logger = logging.getLogger(__name__)
@@ -256,15 +253,6 @@ def _resolve_log_path(log_name: str) -> Optional[Path]:
return None
-def _redact_log_text(text: str) -> str:
- """Strict support-egress scrub (``hermes_cli.debug_redaction``).
-
- Debug/support payloads always use strict URL handling. Ordinary tool output
- retains its separate, less destructive URL policy in ``agent.redact``.
- """
- return redact_debug_support_text(text)
-
-
def _read_tail_bytes(
log_path: Path, size: int, max_bytes: int, tail_lines: int
) -> tuple[bytes, int, bool]:
@@ -329,7 +317,7 @@ def _capture_log_snapshot(
if redact:
# The support scrub needs the complete logical field before either
# the summary-line cap or full-log byte cap can remove its key.
- all_text = _redact_log_text(all_text)
+ all_text = redact_debug_support_text(all_text)
if start_offset and not starts_on_boundary:
all_text = all_text.split("\n", 1)[1] if "\n" in all_text else ""
tail_text = "".join(all_text.splitlines(keepends=True)[-tail_lines:]).rstrip("\n")
@@ -339,7 +327,7 @@ def _capture_log_snapshot(
full_text = f"[... truncated — showing last ~{max_bytes // 1024}KB ...]\n{full_text}"
return LogSnapshot(path=log_path, tail_text=tail_text, full_text=full_text)
except Exception as exc:
- error = redact_debug_support_error(exc)
+ error = redact_debug_support_text(exc)
return LogSnapshot(path=log_path, tail_text=f"(error reading: {error})", full_text=None)
@@ -370,7 +358,7 @@ def _capture_dump(redact: bool = True) -> str:
with contextlib.redirect_stdout(capture), contextlib.suppress(SystemExit):
run_dump(SimpleNamespace(show_keys=False))
text = capture.getvalue()
- return _redact_log_text(text) if redact else text
+ return redact_debug_support_text(text) if redact else text
def collect_debug_report(
@@ -485,7 +473,7 @@ def build_debug_share(
try:
urls[label] = upload_to_pastebin(content, expiry_days=expiry)
except Exception as exc:
- failures.append(f"{label}: {redact_debug_support_error(exc)}")
+ failures.append(f"{label}: {redact_debug_support_text(exc)}")
_schedule_auto_delete(list(urls.values()))
return DebugShareResult(urls=urls, failures=failures, redacted=redact,
auto_delete_seconds=_AUTO_DELETE_SECONDS, report=report)
@@ -547,7 +535,7 @@ def run_debug_share(args):
try:
result = build_debug_share(log_lines=log_lines, expiry=expiry, redact=redact)
except RuntimeError as exc:
- print(f"\nUpload failed: {redact_debug_support_error(exc)}", file=sys.stderr)
+ print(f"\nUpload failed: {redact_debug_support_text(exc)}", file=sys.stderr)
print("\nRun `hermes debug share --local` to print the report instead.\n")
sys.exit(1)
label_width = max(len(k) for k in result.urls)
@@ -604,7 +592,7 @@ def _run_debug_share_nous(args, *, log_lines: int, redact: bool) -> None:
try:
res = share_to_nous(build_nous_bundle(bundle, redact=redact))
except Exception as exc:
- error = redact_debug_support_error(exc)
+ error = redact_debug_support_text(exc)
print(f"\nNous upload failed: {error}\n"
"\nThe Nous diagnostics service may be unavailable or not yet provisioned.\n"
"Run `hermes debug share --local` to print the report instead, "
@@ -642,10 +630,10 @@ def run_debug_delete(args):
f"{redact_debug_support_text(url)} (unexpected response)"
)
except ValueError as exc:
- print(f" ✗ {redact_debug_support_error(exc)}")
+ print(f" ✗ {redact_debug_support_text(exc)}")
except Exception as exc:
safe_url = redact_debug_support_text(url)
- print(f" ✗ Could not delete {safe_url}: {redact_debug_support_error(exc)}")
+ print(f" ✗ Could not delete {safe_url}: {redact_debug_support_text(exc)}")
def run_debug(args):
diff --git a/hermes_cli/debug_redaction.py b/hermes_cli/debug_redaction.py
index 9285fcd2bcc..7e5682b80f9 100644
--- a/hermes_cli/debug_redaction.py
+++ b/hermes_cli/debug_redaction.py
@@ -45,10 +45,6 @@ _SENSITIVE_HEADER_NAMES = (
"set-cookie",
*SECRET_HEADER_NAME_LIST,
)
-_SENSITIVE_HEADER_COMPACT_NAMES = frozenset(
- "".join(ch for ch in name.casefold() if ch.isalnum())
- for name in _SENSITIVE_HEADER_NAMES
-)
_HEADER_NAME_PATTERN = "|".join(re.escape(name) for name in _SENSITIVE_HEADER_NAMES)
_QUOTED_HEADER_RE = re.compile(
rf"(?P<prefix>['\"]?(?:{_HEADER_NAME_PATTERN})['\"]?\s*[:=]\s*)"
@@ -191,8 +187,3 @@ def redact_debug_support_text(value: object, *, max_chars: int | None = None) ->
except Exception:
return REDACTION_UNAVAILABLE
return text[:max_chars] if max_chars is not None else text
-
-
-def redact_debug_support_error(error: object) -> str:
- """Render an outward-facing debug/support failure without raw exception data."""
- return redact_debug_support_text(error)
diff --git a/hermes_cli/web_routers/status.py b/hermes_cli/web_routers/status.py
index 479e289d6b1..9579be47df0 100644
--- a/hermes_cli/web_routers/status.py
+++ b/hermes_cli/web_routers/status.py
@@ -796,7 +796,7 @@ async def run_debug_share_endpoint(body: DebugShareRequest | None = None,
unlike the other diagnostics actions: the point is the shareable URLs, returned as a
structured payload the dashboard renders as copyable links."""
from hermes_cli.debug import build_debug_share
- from hermes_cli.debug_redaction import redact_debug_support_error
+ from hermes_cli.debug_redaction import redact_debug_support_text
req = body or DebugShareRequest()
try:
result = await config_scoped_to_thread(profile, lambda: build_debug_share(
@@ -805,11 +805,11 @@ async def run_debug_share_endpoint(body: DebugShareRequest | None = None,
raise # an unknown ?profile= is the scope's 404, not a failed share
except RuntimeError as exc:
# Required summary-report upload failed (offline / paste service down).
- error = redact_debug_support_error(exc)
+ error = redact_debug_support_text(exc)
raise HTTPException(status_code=502, detail=f"Upload failed: {error}")
except Exception as exc:
_log.exception("debug share failed")
- error = redact_debug_support_error(exc)
+ error = redact_debug_support_text(exc)
raise HTTPException(status_code=500, detail=f"Failed: {error}")
return {"ok": True, "urls": result.urls, "failures": result.failures,
diff --git a/tests/hermes_cli/test_debug.py b/tests/hermes_cli/test_debug.py
index 7037e0db058..29705605470 100644
--- a/tests/hermes_cli/test_debug.py
+++ b/tests/hermes_cli/test_debug.py
@@ -235,7 +235,7 @@ class TestCaptureLogSnapshotRedaction:
):
"""Regression test: redact_sensitive_text short-circuits without force=True.
- If a future refactor drops `force=True` from `_redact_log_text`, this
+ If a future refactor drops `force=True` from `redact_debug_support_text`, this
test fails immediately. Without `force=True`, the redactor returns the
input unchanged when HERMES_REDACT_SECRETS=false, and the share-time
redaction feature ships silently broken for users who opted out of
diff --git a/tests/tui_gateway/test_diagnostics_share_nous.py b/tests/tui_gateway/test_diagnostics_share_nous.py
index 9f9edcbae8d..50725205440 100644
--- a/tests/tui_gateway/test_diagnostics_share_nous.py
+++ b/tests/tui_gateway/test_diagnostics_share_nous.py
@@ -78,7 +78,7 @@ def test_share_nous_attaches_redacted_error_context(captured_upload):
def test_share_nous_client_text_gets_upload_safe_log_redaction(captured_upload):
"""Client artifacts must ride the SAME redactor as backend logs
- (_redact_log_text): secrets AND email addresses — not just the bare
+ (redact_debug_support_text): secrets AND email addresses — not just the bare
secret pass, which leaves emails through (review finding on #92020)."""
secret = "sk-abc123def456ghi789jkl012mno345pqr678"
result = _handler()(
diff --git a/tui_gateway/methods_config.py b/tui_gateway/methods_config.py
index 511e6582d57..fbd0a9884c8 100644
--- a/tui_gateway/methods_config.py
+++ b/tui_gateway/methods_config.py
@@ -531,9 +531,9 @@ def _(rid, params: dict) -> dict:
return _ok(rid, {"ok": True, "view_url": view_url, "upload_id": upload_id,
"expires_at": res.get("expiresAt") or res.get("expires_at")})
except Exception as e:
- from hermes_cli.debug_redaction import redact_debug_support_error
+ from hermes_cli.debug_redaction import redact_debug_support_text
- return _ok(rid, {"ok": False, "error": redact_debug_support_error(e)})
+ return _ok(rid, {"ok": False, "error": redact_debug_support_text(e)})
def register(server) -> None: