Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions filter/src/builtins/http/ai/openai/responses/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,15 @@ fn extract_string_array(body: &serde_json::Value, field: &str) -> Vec<String> {
.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<u32> {
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.
Expand Down
Loading