From 98b71eb8c080c21ca458961805019170c794fdc7 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Sun, 4 Oct 2026 12:14:11 +0300 Subject: * 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. --- test/python/test_search.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'test/python') diff --git a/test/python/test_search.py b/test/python/test_search.py index 1d2118e..d8c5cc5 100644 --- a/test/python/test_search.py +++ b/test/python/test_search.py @@ -24,10 +24,12 @@ class Gn3StubHandler(http.server.BaseHTTPRequestHandler): def do_GET(self): query = urllib.parse.parse_qs(urllib.parse.urlparse(self.path).query) if "&&" in query.get("query", [""])[0]: + # Mirrors production gn3's shape (live-checked Oct 4): + # diagnostic under "error", Python repr under "error_type". body = json.dumps( { - "error": "parsererror", - "error_message": "Syntax error in query: unexpected &&", + "error": "Syntax: AND ", + "error_type": "b'QueryParserError'", } ).encode() self.send_response(http.client.BAD_REQUEST) @@ -91,7 +93,7 @@ class SearchTest(ServerTestCase): status, body = self.get("/search?q=a%26%26b") self.assertEqual(status, http.client.UNPROCESSABLE_ENTITY) self.assertEqual(body["code"], "invalid_query") - self.assertIn("Syntax error in query", body["detail"]) + self.assertIn("Syntax: AND ", body["detail"]) def test_search_caps_limit(self): status, _ = self.get("/search?q=alcohol&limit=9999") -- cgit 1.4.1