From 771115b42bd66d517988950482d12ea9f7a7ca7f Mon Sep 17 00:00:00 2001 From: Accusys Date: Tue, 25 Aug 2026 16:41:37 +0800 Subject: [PATCH] fix: VLM enrich handle nullable start_frame/end_frame --- src/api/search.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/api/search.rs b/src/api/search.rs index 0a26e2a8..0ca53064 100644 --- a/src/api/search.rs +++ b/src/api/search.rs @@ -167,25 +167,31 @@ async fn enrich_vlm_from_pg( "SELECT start_frame, end_frame, vlm_description FROM {tp_table} \ WHERE file_uuid = $1 AND trace_id = $2" ); - tracing::info!("[VLM-enrich] Query: {}, file_uuid={}, trace_id={}", query, file_uuid, trace_id); let result = sqlx::query_as(&query) .bind(file_uuid) .bind(trace_id) .fetch_all(db.pool()) .await; - tracing::info!("[VLM-enrich] Query result: {:?}", result.as_ref().map(|r| r.len())); - let rows: Vec<(i64, i64, Option)> = result.ok()?; + let rows: Vec<(Option, Option, Option)> = match result { + Ok(r) => r, + Err(e) => { + tracing::warn!("[VLM-enrich] Query failed: {}", e); + return None; + } + }; let (start_frame, end_frame, vlm_desc) = rows.into_iter().next()?; let text = vlm_desc.unwrap_or_default(); + let sf = start_frame.unwrap_or(0); + let ef = end_frame.unwrap_or(0); Some(SearchResult { id: 0, file_uuid: Some(file_uuid.to_string()), parent_id: 0, scene_order: None, - start_frame, - end_frame, + start_frame: sf, + end_frame: ef, fps: 0.0, start_time: 0.0, end_time: 0.0,