Skip to content

Improve error handling in search endpoint #453

@Syndesi

Description

@Syndesi

Error messages thrown during the search request handling should be somewhat passed on, e.g.:

curl \
  -k \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer secret-token:PIPeJGUt7c00ENn8a5uDlc" \
  -d '{"debug": true, "steps": [{"type": "elasticsearch-query-dsl-mixin", "query": {"query": {"match": {"description": {"query": "lily"}}}}}]}' \
  https://reference-dataset.ember-nexus.dev/search

Results in this error:

{
  "type": "http://reference-dataset.ember-nexus.dev/error/500/internal-server-error",
  "title": "Internal server error",
  "status": 500,
  "detail": "Internal server error, see log."
}

Which is not useful at all.

The corresponding error inside the server's log file is:

Exception of type Elastic\Elasticsearch\Exception\ClientResponseException got thrown during search step 1 (type
elasticsearch-query-dsl-mixin): 400 Bad Request: {"error":{"root_cause":[{"type":"parsing_exception","reason":"unknown
query [query]","line":1,"col":73}],"type":"x_content_parse_exception","reason":"[1:73] [bool] failed to parse field
[must]","caused_by":{"type":"parsing_exception","reason":"unknown query [query]","line":1,"col":73,"caused_by":{"type":
"named_object_not_found_exception","reason":"[1:73] unknown field [query]"}}},"status":400}

Acceptance criteria:

  • Add integration tests which query the API with known bad queries, and compare the returned exception text against stored helpful ones.
  • Make sure that common errors, e.g. bad Elasticsearch queries, are correctly forwarded to the user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementImproving existing functionalities.

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions