Skip to content

Use Claude Code, Codex, VSCode, Pi, and OpenCode (and 6 other harnesses) for free (1.3B+ free tokens) from your terminal, app, IDE, or phone, and now from the browser with native browser sessions (multi-harness + multi-model) like OpenClaw (voice supported + ToS friendly)

Python

patch: redact additional API key headers in traces (#2046)

Ali Khokhar5ac3cbb831b4
diff --git a/src/free_claude_code/core/trace.py b/src/free_claude_code/core/trace.py
index 6f0cf0bb..38077b57 100644
--- a/src/free_claude_code/core/trace.py
+++ b/src/free_claude_code/core/trace.py
@@ -22,6 +22,8 @@ _SECRET_VALUE_KEYS = frozenset(
for k in (
"authorization",
"x-api-key",
+ "x-goog-api-key",
+ "api-key",
"anthropic-auth-token",
"api_key",
"password",
diff --git a/tests/core/test_trace.py b/tests/core/test_trace.py
index 47bbd7f8..5db339fb 100644
--- a/tests/core/test_trace.py
+++ b/tests/core/test_trace.py
@@ -99,6 +99,29 @@ def test_sanitize_masks_nested_api_key_strings() -> None:
assert out["outer"]["text"] == "visible"
+ "header", ["x-goog-api-key", "X-Goog-Api-Key", "api-key", "Api-Key"]
+)
+def test_trace_redacts_provider_api_keys_in_json(tmp_path: Path, header: str) -> None:
+ log_file = str(tmp_path / "credentials.log")
+ configure_logging(log_file, force=True, level="DEBUG")
+ headers = {header: "dummy-provider-secret", "content-type": "application/json"}
+
+ trace_event(
+ stage="ingress",
+ event="request.received",
+ source="unit",
+ requests=[{"headers": headers}],
+ )
+
+ payload = _trace_payloads(log_file)[0]
+ assert payload["requests"] == [
+ {"headers": {header: "<redacted>", "content-type": "application/json"}}
+ ]
+ assert "dummy-provider-secret" not in Path(log_file).read_text(encoding="utf-8")
+ assert headers[header] == "dummy-provider-secret"
+
+
@pytest.mark.asyncio
async def test_traced_async_stream_logs_completion(tmp_path) -> None:
log_file = str(tmp_path / "complete.log")