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

fix: Replace RequestError with BadRequestError #3172

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/api/controllers/search_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 NotFoundError, BadRequestError
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the lint error we're seeing is about the order of the imports. Imports are sorted alphabetically so placing BadRequestError first should fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood @dhruvkb, will change in a while.

from elasticsearch_dsl import Q, Search
from elasticsearch_dsl.query import EMPTY_QUERY, MoreLikeThis, Query
from elasticsearch_dsl.response import Hit, Response
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions documentation/meta/monitoring/cloudwatch_logs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down