You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2021/06/06 10:40:06 UTC

[incubator-ponymail-foal] branch master updated: Also return 500 on syntax error here

This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git


The following commit(s) were added to refs/heads/master by this push:
     new abcb5db  Also return 500 on syntax error here
abcb5db is described below

commit abcb5db9413dc6609fbc1d87d1eeaa10152a69e0
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Sun Jun 6 12:40:01 2021 +0200

    Also return 500 on syntax error here
---
 server/endpoints/mbox.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/server/endpoints/mbox.py b/server/endpoints/mbox.py
index 87d3256..0a21668 100644
--- a/server/endpoints/mbox.py
+++ b/server/endpoints/mbox.py
@@ -29,7 +29,10 @@ async def process(
     server: plugins.server.BaseServer, session: plugins.session.SessionObject, indata: dict,
 ) -> typing.Union[dict, aiohttp.web.Response]:
 
-    query_defuzzed = plugins.defuzzer.defuzz(indata)
+    try:
+        query_defuzzed = plugins.defuzzer.defuzz(indata)
+    except AssertionError as e:  # If defuzzer encounters syntax errors, it will throw an AssertionError
+        return aiohttp.web.Response(headers={"content-type": "text/plain",}, status=500, text=str(e))
     results = await plugins.messages.query(session, query_defuzzed, query_limit=server.config.database.max_hits,)
 
     sources = []