Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(observability): scrub the backend error code before logging it

M3gA-Mind158a117ad27b
diff --git a/crates/openhuman-core/src/core/observability_reporting.rs b/crates/openhuman-core/src/core/observability_reporting.rs
index e33cce8e2f..44de6517cf 100644
--- a/crates/openhuman-core/src/core/observability_reporting.rs
+++ b/crates/openhuman-core/src/core/observability_reporting.rs
@@ -453,6 +453,8 @@ fn report_expected_message(kind: ExpectedErrorKind, message: &str, domain: &str,
let code = crate::inference::registry::classify_backend_error(None, raw)
.and_then(|classification| classification.token)
.unwrap_or_default();
+ // The token echoes the backend's errorCode verbatim; scrub it too.
+ let code = crate::core::log_redaction::scrub_secrets(&code);
tracing::warn!(
domain = domain,
operation = operation,
diff --git a/crates/openhuman-core/src/core/observability_tests.rs b/crates/openhuman-core/src/core/observability_tests.rs
index c1d7a69778..5016996e38 100644
--- a/crates/openhuman-core/src/core/observability_tests.rs
+++ b/crates/openhuman-core/src/core/observability_tests.rs
@@ -202,4 +202,21 @@ fn a_backend_error_code_survives_a_secret_in_the_message() {
let logs = captured_logs(|| report_error_or_expected(&body, "d", "o", &[]));
assert!(logs.contains("errorCode=fixture-owned"), "{logs}");
assert!(!logs.contains("sekrit"), "{logs}");
+
+ // An errorCode that is itself secret-shaped is scrubbed too.
+ let leaky = "OpenHuman API error (400): {\"error\":{\"errorCode\":\"code-x\"}}";
+ register_backend_classifier_fixture(
+ leaky,
+ BackendErrorClassification {
+ provider_owned: true,
+ backend_owned: true,
+ reportable: false,
+ token: Some("sk-proj-LEAKEDLEAKEDLEAKED".to_string()),
+ kind: Some(BackendErrorKind::Internal),
+ malformed_bad_request: false,
+ },
+ );
+ let logs = captured_logs(|| report_error_or_expected(&leaky, "d", "o", &[]));
+ assert!(logs.contains("errorCode=[REDACTED]"), "{logs}");
+ assert!(!logs.contains("LEAKED"), "{logs}");
}