Skip to content

Commit

Permalink
* Catching TransportError in opensearch (#3233)
Browse files Browse the repository at this point in the history
* Make search error messages more actionable
  • Loading branch information
jkppr authored Nov 28, 2024
1 parent 4379ca2 commit cbefa31
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion timesketch/frontend-ng/src/components/Explore/EventList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,14 @@ export default {
}
})
.catch((e) => {
this.errorSnackBar('Sorry, there was a problem fetching your search results. Please try again.')
let msg = 'Sorry, there was a problem fetching your search results. Error: "'+ e.response.data.message +'"'
if (e.response.data.message.includes('too_many_nested_clauses')) {
msg = 'Sorry, your query is too complex. Use field-specific search (like "message:(<query terms>)") and try again.'
this.errorSnackBar(msg)
} else {
this.errorSnackBar(msg)
}
console.error('Error message: ' + msg)
console.error(e)
})
},
Expand Down
3 changes: 2 additions & 1 deletion timesketch/lib/datastores/opensearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from opensearchpy.exceptions import ConnectionTimeout
from opensearchpy.exceptions import NotFoundError
from opensearchpy.exceptions import RequestError
from opensearchpy.exceptions import TransportError

# pylint: disable=redefined-builtin
from opensearchpy.exceptions import ConnectionError
Expand Down Expand Up @@ -607,7 +608,7 @@ def search(
_source_includes=return_fields,
scroll=scroll_timeout,
)
except RequestError as e:
except (RequestError, TransportError) as e:
root_cause = e.info.get("error", {}).get("root_cause")
if root_cause:
error_items = []
Expand Down

0 comments on commit cbefa31

Please sign in to comment.