From 4fe18d35481062adc224d14d04dfe92bafa1f227 Mon Sep 17 00:00:00 2001 From: cyberpapi Date: Tue, 24 Feb 2026 16:12:55 -0500 Subject: [PATCH] fix(telegram): redact raw response body in register_commands error log Co-Authored-By: Claude Opus 4.6 --- src/channels/telegram.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/channels/telegram.rs b/src/channels/telegram.rs index b46740706..51138577c 100644 --- a/src/channels/telegram.rs +++ b/src/channels/telegram.rs @@ -915,7 +915,20 @@ impl TelegramChannel { if !resp.status().is_success() { let status = resp.status(); let text = resp.text().await.unwrap_or_default(); - tracing::warn!("setMyCommands failed: status={status}, body={text}"); + // Only log Telegram's error_code and description, not the full body + let detail = serde_json::from_str::(&text) + .ok() + .and_then(|v| { + let code = v.get("error_code"); + let desc = v.get("description").and_then(|d| d.as_str()); + match (code, desc) { + (Some(c), Some(d)) => Some(format!("error_code={c}, description={d}")), + (_, Some(d)) => Some(format!("description={d}")), + _ => None, + } + }) + .unwrap_or_else(|| "no parseable error detail".to_string()); + tracing::warn!("setMyCommands failed: status={status}, {detail}"); } else { tracing::info!("Telegram bot commands registered successfully"); }