Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

search: check for error in query_result before returning JSON #588

Open
GraemeWatt opened this issue Dec 12, 2022 · 0 comments
Open

search: check for error in query_result before returning JSON #588

GraemeWatt opened this issue Dec 12, 2022 · 0 comments
Labels
complexity: low priority: medium type: bug Indicates an unexpected problem or unintended behaviour

Comments

@GraemeWatt
Copy link
Member

If search results are requested in JSON format, the current code tries to calculate query_result['hits'] and return the JSON results without checking if there is an error in the query_result:

query_result['hits'] = {'total': query_result['total']}
return jsonify(query_result)

An invalid query like q=%27%5B0%5D gives an exception KeyError: 'total', e.g. Sentry event. A JSON error message should be returned instead.

@GraemeWatt GraemeWatt added type: bug Indicates an unexpected problem or unintended behaviour priority: medium complexity: low labels Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity: low priority: medium type: bug Indicates an unexpected problem or unintended behaviour
Projects
Status: To do
Development

No branches or pull requests

1 participant