Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(search): return 400 bad request if no valid terms are provided (#690)

Will Hutchinsonae567abc71c6
diff --git a/rust/cloud-storage/search_service/src/api/search/simple/mod.rs b/rust/cloud-storage/search_service/src/api/search/simple/mod.rs
index dc2feace0c..fab496412a 100644
--- a/rust/cloud-storage/search_service/src/api/search/simple/mod.rs
+++ b/rust/cloud-storage/search_service/src/api/search/simple/mod.rs
@@ -38,7 +38,7 @@ pub enum SearchError {
#[error("query must be at least 3 characters")]
InvalidQuerySize,
/// No query or terms provided
- #[error("query or terms must be provided")]
+ #[error("query or terms must be provided and at least 3 characters")]
NoQueryOrTermsProvided,
/// Opensearch error occurred
#[error("unable to search")]
diff --git a/rust/cloud-storage/search_service/src/api/search/simple/simple_unified.rs b/rust/cloud-storage/search_service/src/api/search/simple/simple_unified.rs
index a9999715b2..511adca165 100644
--- a/rust/cloud-storage/search_service/src/api/search/simple/simple_unified.rs
+++ b/rust/cloud-storage/search_service/src/api/search/simple/simple_unified.rs
@@ -57,6 +57,10 @@ pub(in crate::api::search) async fn perform_unified_search(
_ => vec![],
};
+ if terms.is_empty() {
+ return Err(SearchError::NoQueryOrTermsProvided);
+ }
+
let match_type = req.match_type;
let disable_recency = req.disable_recency;