Merge pull request #69 from fettpl/fix/llm-error-leakage
fix: stop leaking LLM error details to clients
This commit is contained in:
commit
b931aeb56c
2 changed files with 7 additions and 4 deletions
|
|
@ -302,7 +302,8 @@ async fn handle_webhook(
|
|||
(StatusCode::OK, Json(body))
|
||||
}
|
||||
Err(e) => {
|
||||
let err = serde_json::json!({"error": format!("LLM error: {e}")});
|
||||
tracing::error!("LLM error: {e:#}");
|
||||
let err = serde_json::json!({"error": "Internal error processing your request"});
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, Json(err))
|
||||
}
|
||||
}
|
||||
|
|
@ -405,8 +406,10 @@ async fn handle_whatsapp_message(State(state): State<AppState>, body: Bytes) ->
|
|||
}
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::error!("LLM error for WhatsApp message: {e}");
|
||||
let _ = wa.send(&format!("⚠️ Error: {e}"), &msg.sender).await;
|
||||
tracing::error!("LLM error for WhatsApp message: {e:#}");
|
||||
let _ = wa
|
||||
.send("Sorry, I couldn't process your message right now.", &msg.sender)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ fn hex_encode(data: &[u8]) -> String {
|
|||
/// Hex-decode a hex string to bytes.
|
||||
#[allow(clippy::manual_is_multiple_of)]
|
||||
fn hex_decode(hex: &str) -> Result<Vec<u8>> {
|
||||
if hex.len() % 2 != 0 {
|
||||
if !hex.len().is_multiple_of(2) {
|
||||
anyhow::bail!("Hex string has odd length");
|
||||
}
|
||||
(0..hex.len())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue