Skip to content

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

fix(tinyhumans): redact endpoint details in validation errors

Steven Enamakel081f705fe1aa
diff --git a/crates/openhuman-tinyhumans/src/inference/managed_embedding.rs b/crates/openhuman-tinyhumans/src/inference/managed_embedding.rs
index c9436752a1..bf66d6a8ff 100644
--- a/crates/openhuman-tinyhumans/src/inference/managed_embedding.rs
+++ b/crates/openhuman-tinyhumans/src/inference/managed_embedding.rs
@@ -53,7 +53,8 @@ fn build_cloud_model(
if !is_managed_endpoint_for_api_key(&key_endpoint) {
return Err(tinyinference_embeddings::Error::Validation(format!(
"refusing to send the TinyHumans API key over a non-HTTPS, non-loopback \
- endpoint: {key_endpoint}"
+ endpoint: {}",
+ super::managed_model::endpoint_origin_for_log(&key_endpoint)
)));
}
log::debug!("[tinyhumans][embeddings] authenticating with api-key");
diff --git a/crates/openhuman-tinyhumans/src/inference/managed_model.rs b/crates/openhuman-tinyhumans/src/inference/managed_model.rs
index 491f52d7c8..6b552a137a 100644
--- a/crates/openhuman-tinyhumans/src/inference/managed_model.rs
+++ b/crates/openhuman-tinyhumans/src/inference/managed_model.rs
@@ -45,7 +45,8 @@ impl ManagedOptions {
if !is_managed_endpoint_for_api_key(endpoint) {
anyhow::bail!(
"refusing to send the TinyHumans API key to an unmanaged or insecure \
- endpoint: {endpoint} — use the managed backend or loopback for local testing"
+ endpoint: {} — use the managed backend or loopback for local testing",
+ endpoint_origin_for_log(endpoint)
);
}
log::debug!(
@@ -62,6 +63,16 @@ impl ManagedOptions {
}
}
+/// Returns only a URL origin for diagnostics, never userinfo, path, query, or
+/// fragment data. Invalid and opaque URLs use a constant placeholder.
+pub(super) fn endpoint_origin_for_log(endpoint: &str) -> String {
+ url::Url::parse(endpoint)
+ .ok()
+ .map(|url| url.origin().ascii_serialization())
+ .filter(|origin| origin != "null")
+ .unwrap_or_else(|| "<invalid endpoint>".to_string())
+}
+
/// Constructs the owning TinyInference model with OpenHuman's rotating
/// credential source and host-specific connection policy.
pub(super) fn build_chat_model(