From 405211d3ce1367c087d76e3baa24cb54f627109f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Mon, 22 Jun 2026 16:56:01 +0200 Subject: [PATCH] fix(filter): log when max_tool_calls value is not representable as u32 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #647 Signed-off-by: Sébastien Han --- .../src/builtins/http/ai/openai/responses/state.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/filter/src/builtins/http/ai/openai/responses/state.rs b/filter/src/builtins/http/ai/openai/responses/state.rs index 676d4b1d..b7bdc1cd 100644 --- a/filter/src/builtins/http/ai/openai/responses/state.rs +++ b/filter/src/builtins/http/ai/openai/responses/state.rs @@ -183,11 +183,15 @@ fn extract_string_array(body: &serde_json::Value, field: &str) -> Vec { .unwrap_or_default() } -/// Extract a `u32` field by name. +/// Extract a `u32` field by name, logging when a value is present +/// but not representable as `u32`. fn extract_u32(body: &serde_json::Value, field: &str) -> Option { - body.get(field) - .and_then(serde_json::Value::as_u64) - .and_then(|v| u32::try_from(v).ok()) + let raw = body.get(field)?; + let result = raw.as_u64().and_then(|v| u32::try_from(v).ok()); + if result.is_none() { + tracing::debug!(field, %raw, "ignoring non-u32 value"); + } + result } /// Extract a bool field by name, returning a default if absent.