FlowKit icon indicating copy to clipboard operation
FlowKit copied to clipboard

API returns invalid json if SQL query fails

Open jc-harrison opened this issue 2 years ago • 1 comments

Describe the bug

If a FlowAPI get_query_result request successfully gets result-retrieval SQL from flowmachine, but an error occurs while executing the SQL query, the API will send a 200 response with incomplete content ('{"query_id":"<query_id>", "query_result":['), because the result-streaming begins before the query is actually executed. This results in the following misleading error in flowclient:

JSONDecodeError: Expecting value: line 1 column 65 (char 64)

Product

FlowAPI

Version

1.18.1

Expected behaviour

If the result-retrieval SQL fails to execute, the response code should indicate an error (probably 500).

jc-harrison avatar Jul 03 '23 14:07 jc-harrison

Part of the issue is that we catch a bare exception, log it, and then carry on, where we should almost certainly re-raise or throw a new one.

greenape avatar Aug 14 '23 10:08 greenape