Skip to content

Commit d75e6b3

Browse files
committed
fix: search resilience — embed error fallback, consistent obs_type handling
1 parent 59c1cd4 commit d75e6b3

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

crates/cli/src/commands/search.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ pub(crate) async fn run_search(
2121
)))
2222
};
2323
let search = SearchService::new(storage, embeddings, None, config.dedup_threshold);
24-
let obs_type_lower = obs_type.map(|t| t.to_lowercase());
2524
let results = search
2625
.smart_search(
2726
Some(&query),
2827
project.as_deref(),
29-
obs_type_lower.as_deref(),
28+
obs_type.as_deref(),
3029
None,
3130
None,
3231
limit,

crates/service/src/search_service/hybrid_ops.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,12 @@ impl SearchService {
133133
)
134134
})
135135
.await;
136-
return self.with_cb(result);
136+
match self.with_cb(result) {
137+
Ok(results) => return Ok(results),
138+
Err(e) => {
139+
tracing::warn!(error = %e, "hybrid_search_v2_with_filters failed, falling back to text-only search_with_filters");
140+
}
141+
}
137142
}
138143
let result = self
139144
.storage
@@ -196,14 +201,19 @@ impl SearchService {
196201
}
197202
}
198203

199-
/// Try to embed the query. Returns `Ok(None)` if embeddings are not configured.
200-
/// Returns `Ok(Some(vec))` on success, `Err` on embedding failure.
204+
/// Try to embed the query. Returns `Ok(None)` if embeddings are not configured
205+
/// or if embedding generation fails (graceful degradation to text-only search).
201206
async fn try_embed(&self, query: &str) -> Result<Option<Vec<f32>>, ServiceError> {
202207
let Some(ref emb) = self.embeddings else {
203208
return Ok(None);
204209
};
205-
let vec = embed_query(emb, query).await?;
206-
Ok(Some(vec))
210+
match embed_query(emb, query).await {
211+
Ok(vec) => Ok(Some(vec)),
212+
Err(e) => {
213+
tracing::warn!(error = %e, "Embedding generation failed, falling back to text-only search");
214+
Ok(None)
215+
}
216+
}
207217
}
208218
}
209219

0 commit comments

Comments
 (0)