From 7ff0f1525e42f948495970a0bb6227d4c3dfac43 Mon Sep 17 00:00:00 2001 From: Oleksiy Syvokon Date: Tue, 12 Aug 2025 21:49:19 +0300 Subject: [PATCH] open_ai: Log inputs that caused parsing errors (#36063) Release Notes: - N/A Co-authored-by: Michael Sloan --- Cargo.lock | 1 + crates/open_ai/Cargo.toml | 1 + crates/open_ai/src/open_ai.rs | 10 +++++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 72c5da3a34..d24a399c1c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11242,6 +11242,7 @@ dependencies = [ "anyhow", "futures 0.3.31", "http_client", + "log", "schemars", "serde", "serde_json", diff --git a/crates/open_ai/Cargo.toml b/crates/open_ai/Cargo.toml index 2d40cd2735..bae00f0a8e 100644 --- a/crates/open_ai/Cargo.toml +++ b/crates/open_ai/Cargo.toml @@ -20,6 +20,7 @@ anyhow.workspace = true futures.workspace = true http_client.workspace = true schemars = { workspace = true, optional = true } +log.workspace = true serde.workspace = true serde_json.workspace = true strum.workspace = true diff --git a/crates/open_ai/src/open_ai.rs b/crates/open_ai/src/open_ai.rs index 4697d71ed3..a6fd03a296 100644 --- a/crates/open_ai/src/open_ai.rs +++ b/crates/open_ai/src/open_ai.rs @@ -445,7 +445,15 @@ pub async fn stream_completion( Ok(ResponseStreamResult::Err { error }) => { Some(Err(anyhow!(error))) } - Err(error) => Some(Err(anyhow!(error))), + Err(error) => { + log::error!( + "Failed to parse OpenAI response into ResponseStreamResult: `{}`\n\ + Response: `{}`", + error, + line, + ); + Some(Err(anyhow!(error))) + } } } }