Skip to content
New issue

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

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

Already on GitHub? # to your account

Improve error handling in respond to JSON requests #2375

Closed
5 tasks done
donhardman opened this issue Jul 4, 2024 · 2 comments
Closed
5 tasks done

Improve error handling in respond to JSON requests #2375

donhardman opened this issue Jul 4, 2024 · 2 comments

Comments

@donhardman
Copy link
Contributor

donhardman commented Jul 4, 2024

Bug Description:

Currently, we have an issue with hard-to-read error messages when incorrect payloads are sent to the /search endpoint. The goal of this task is to improve the error message and make it easier to identify the related issue in the payload, which may be large.

Here's an example I came up with:

{
  "index": "test",
  "query": {
    "match": {
      "*": {
        "bool": {
          "should": [
            {
              "match": {
                "*": "hello boys"
              }
            }
          ]
        }
      }
    }
  }
}

When we send the request:

curl -d @request.json localhost:9308/search
{"error":"table test: query error: \"query\" property missing"}

The error indicates that the 'query' field is missing. When we look into the documentation, we find that in match and struct fields, we should include a "query" field and an optional "operator" field. However, the docs don't explicitly state that we can't use a nested match with bool inside it, which isn't very obvious.

It seems like a good idea to improve our error message by pointing out exactly which structure we expect the query to be specified in. For example, if we expect it in match.*, we could provide the path to the original structure where the error occurred. This would be really helpful when investigating incorrectly built queries, especially since they can be quite nested and large.

Manticore Search Version:

Latest dev version

Operating System Version:

Ubuntu Jammy

Have you tried the latest development version?

Yes

Internal Checklist:

To be completed by the assignee. Check off tasks that have been completed or are not applicable.

  • Implementation completed
  • Tests developed
  • Documentation updated
  • Documentation reviewed
  • Changelog updated
@tomatolog
Copy link
Contributor

it worth to add full path to the node that causes error - that can be done by run another parsing pass after the initial error returned with additional argument to print \ collect full path from the recursive parsing.

@tomatolog
Copy link
Contributor

I fixed at 75b6b51 the error output for JSON query and now it includes the JSON path to the point the error happens like

"error": "table test,test2: query error: unknown full-text node 'missed' at '/query/bool/should/bool/must/missed'"

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants