Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
Keep URL paths out of webhook logs and failure reasons
Lin (kwant bot)f9ea03104d5f
diff --git a/src/server/continuity.rs b/src/server/continuity.rsindex 9303c6e5..1b3bf89e 100644--- a/src/server/continuity.rs+++ b/src/server/continuity.rs@@ -698,15 +698,17 @@ pub async fn save_notify_settings(Ok(())}-/// A URL for logs: scheme, host and path only (ntfy topics and tokens often sit in the query).+/// A URL for logs: scheme, host and non-default port only. The path is the secret on ntfy+/// (it names the topic) and tokens often sit in the query or userinfo, so all are dropped.pub fn loggable_url(raw: &str) -> String {match reqwest::Url::parse(raw) {- Ok(u) => format!(- "{}://{}{}",- u.scheme(),- u.host_str().unwrap_or(""),- u.path()- ),+ Ok(u) => {+ let host = u.host_str().unwrap_or("");+ match u.port() {+ Some(port) => format!("{}://{host}:{port}", u.scheme()),+ None => format!("{}://{host}", u.scheme()),+ }+ }Err(_) => "<invalid url>".into(),}}@@ -931,10 +933,13 @@ mod tests {assert!(check_webhook_url("https://user:[email protected]/t").is_err());assert!(check_webhook_url("file:///etc/passwd").is_err());assert!(check_webhook_url("nonsense").is_err());- assert_eq!(- loggable_url("https://ntfy.sh/topic?auth=secret#x"),- "https://ntfy.sh/topic"- );+ assert_eq!(loggable_url("https://ntfy.sh/topic?auth=secret#x"), "https://ntfy.sh");+ let logged = loggable_url("https://user:[email protected]/secret-topic?x=1");+ assert_eq!(logged, "https://ntfy.sh");+ assert!(!logged.contains("secret-topic") && !logged.contains("pw"));+ assert_eq!(loggable_url("https://ntfy.sh:443/t"), "https://ntfy.sh");+ assert_eq!(loggable_url("https://10.0.0.5:8443/t"), "https://10.0.0.5:8443");+ assert_eq!(loggable_url("not a url"), "<invalid url>");}#[test]diff --git a/src/server/routes.rs b/src/server/routes.rsindex 3b58bb05..f22cd3bf 100644--- a/src/server/routes.rs+++ b/src/server/routes.rs@@ -765,8 +765,9 @@ async fn try_kwant_turn(reply.map_err(|why| truncate_chars(&scrub_urls(why.trim()), MAX_FAILURE_CHARS).to_string())}-/// `text` with every URL's userinfo and query dropped, so a failure reason that names a-/// custom endpoint can be stored without the credentials some endpoints carry there.+/// `text` with every URL cut to scheme and host, so a failure reason that names a custom+/// endpoint can be stored without the credentials some endpoints carry in the userinfo,+/// path or query.fn scrub_urls(text: &str) -> String {text.split(' ').map(|word| {@@ -775,13 +776,13 @@ fn scrub_urls(text: &str) -> String {};let (scheme, rest) = word.split_at(scheme_end + 3);let host_end = rest.find(['/', '?', '#']).unwrap_or(rest.len());- let (authority, path) = rest.split_at(host_end);+ let (authority, tail) = rest.split_at(host_end);let host = authority.rsplit_once('@').map_or(authority, |(_, h)| h);- let path = match path.find(['?', '#']) {- Some(q) => format!("{}?…", &path[..q]),- None => path.to_string(),- };- format!("{scheme}{host}{path}")+ if tail.is_empty() {+ format!("{scheme}{host}")+ } else {+ format!("{scheme}{host}/…")+ }}).collect::<Vec<_>>().join(" ")@@ -2575,9 +2576,13 @@ mod tests {fn failure_reasons_drop_url_credentials() {assert_eq!(scrub_urls("HTTP API error: error sending request for url (https://u:[email protected]/v1/chat?key=sk-123&x=1)"),- "HTTP API error: error sending request for url (https://llm.example/v1/chat?…"+ "HTTP API error: error sending request for url (https://llm.example/…");- assert_eq!(scrub_urls("see http://host:8080/a#frag now"), "see http://host:8080/a?… now");+ assert_eq!(scrub_urls("see http://host:8080/a#frag now"), "see http://host:8080/… now");+ let keyed = scrub_urls("401 from https://llm.example/v1/key/sk-path-secret/chat");+ assert_eq!(keyed, "401 from https://llm.example/…");+ assert!(!keyed.contains("sk-path-secret"));+ assert_eq!(scrub_urls("down: https://llm.example"), "down: https://llm.example");assert_eq!(scrub_urls("not logged in; run `codex login`"), "not logged in; run `codex login`");}}