about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorAlexander_Kabui <alexanderkabua@gmail.com>2026-10-04 12:14:11 +0300
committerAlexander_Kabui <alexanderkabua@gmail.com>2026-10-05 21:53:57 +0300
commit98b71eb8c080c21ca458961805019170c794fdc7 (patch)
treec08c751223fb13f4721a5a95e161cefba5a8ee80 /tests
parent1b40aa1f557eadd8894996fff6081d2917e28f20 (diff)
downloadgenenetwork4-98b71eb8c080c21ca458961805019170c794fdc7.tar.gz
* src/routes/search.rs (search): map any gn3 4xx with an error body to 422
Production gn3 puts the diagnostic under "error" and leaks Python
reprs under "error_type", so the old "parsererror" match never
fired and malformed queries fell to 502 with no actionable feedback.
Match on "error" alone; gn3 5xx stays 502.

* tests/search.rs test/python/test_search.py (search): stub replays
production's error body shape.
Diffstat (limited to 'tests')
-rw-r--r--tests/search.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/search.rs b/tests/search.rs
index 7ba9791..5197ffd 100644
--- a/tests/search.rs
+++ b/tests/search.rs
@@ -25,12 +25,14 @@ const FIXTURE: &str = include_str!("../test/data/search_alcohol_phenotype.json")
 /// Stands in for gn3's /api/search during tests.
 async fn serve_gn3(Query(params): Query<HashMap<String, String>>) -> (StatusCode, String) {
     if params.get("query").is_some_and(|q| q.contains("&&")) {
-        // Mirrors gn3's shape for unparseable xapian queries.
+        // Mirrors production gn3's shape for rejected xapian queries
+        // (live-checked Oct 4): the diagnostic is under "error" and
+        // "error_type" leaks a Python repr.
         return (
             StatusCode::BAD_REQUEST,
             json!({
-                "error": "parsererror",
-                "error_message": "Syntax error in query: unexpected &&"
+                "error": "Syntax: <expression> AND <expression>",
+                "error_type": "b'QueryParserError'"
             })
             .to_string(),
         );
@@ -99,7 +101,7 @@ async fn search_proxy_scenarios() {
         body["detail"]
             .as_str()
             .unwrap()
-            .contains("Syntax error in query")
+            .contains("Syntax: <expression> AND <expression>")
     );
 
     // 4. limit is capped: ask for more than 100, the stub still sees a