From 8e447eda940de48261fb390877fd9f082b2680e0 Mon Sep 17 00:00:00 2001 From: Ankit Kumar <104667338+CodeAnk2829@users.noreply.github.com> Date: Tue, 10 Oct 2023 17:53:45 +0530 Subject: [PATCH] fix: Replace RequestError with BadRequestError (#3172) * fix: Replace RequestError with BadRequestError * Lint --------- Co-authored-by: Olga Bulat --- api/api/controllers/search_controller.py | 4 ++-- documentation/meta/monitoring/cloudwatch_logs/index.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/api/controllers/search_controller.py b/api/api/controllers/search_controller.py index f0cf402e105..921b50400ee 100644 --- a/api/api/controllers/search_controller.py +++ b/api/api/controllers/search_controller.py @@ -9,7 +9,7 @@ from django.conf import settings from django.core.cache import cache -from elasticsearch.exceptions import NotFoundError, RequestError +from elasticsearch.exceptions import BadRequestError, NotFoundError from elasticsearch_dsl import Q, Search from elasticsearch_dsl.query import EMPTY_QUERY, MoreLikeThis, Query from elasticsearch_dsl.response import Hit, Response @@ -447,7 +447,7 @@ def search( if settings.VERBOSE_ES_RESPONSE: log.info(pprint.pprint(search_response.to_dict())) - except (RequestError, NotFoundError) as e: + except (BadRequestError, NotFoundError) as e: raise ValueError(e) results = _post_process_results( diff --git a/documentation/meta/monitoring/cloudwatch_logs/index.md b/documentation/meta/monitoring/cloudwatch_logs/index.md index 5677e9e4c59..5d143e8becc 100644 --- a/documentation/meta/monitoring/cloudwatch_logs/index.md +++ b/documentation/meta/monitoring/cloudwatch_logs/index.md @@ -184,7 +184,7 @@ outputs stack traces, for example, this means that stack traces will be split across multiple lines. Take the following, real stack trace: ``` -2023-06-04T00:32:12.485Z 2023-06-04 00:32:12,485 ERROR tasks.py:220 - Error processing task `CREATE_AND_POPULATE_FILTERED_INDEX` for `audio`: RequestError(400, 'search_phase_execution_exception', 'too_many_clauses: maxClauseCount is set to 1024') +2023-06-04T00:32:12.485Z 2023-06-04 00:32:12,485 ERROR tasks.py:220 - Error processing task `CREATE_AND_POPULATE_FILTERED_INDEX` for `audio`: BadRequestError(400, 'search_phase_execution_exception', 'too_many_clauses: maxClauseCount is set to 1024') 2023-06-04T00:32:12.539Z Process Process-5: 2023-06-04T00:32:12.541Z Traceback (most recent call last): 2023-06-04T00:32:12.541Z File "/usr/local/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap @@ -211,7 +211,7 @@ across multiple lines. Take the following, real stack trace: 2023-06-04T00:32:12.541Z self._raise_error(response.status_code, raw_data) 2023-06-04T00:32:12.541Z File "/venv/lib/python3.11/site-packages/elasticsearch/connection/base.py", line 328, in _raise_error 2023-06-04T00:32:12.541Z raise HTTP_EXCEPTIONS.get(status_code, TransportError)( -2023-06-04T00:32:12.541Z elasticsearch.exceptions.RequestError: RequestError(400, 'search_phase_execution_exception', 'too_many_clauses: maxClauseCount is set to 1024') +2023-06-04T00:32:12.541Z elasticsearch.exceptions.BadRequestError: BadRequestError(400, 'search_phase_execution_exception', 'too_many_clauses: maxClauseCount is set to 1024') ``` Each line (prepended with a timestamp), is a separate log event. The implication