Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Error handling #210

Merged
merged 20 commits into from
Jun 22, 2021
Merged

Error handling #210

merged 20 commits into from
Jun 22, 2021

Conversation

MarinPostma
Copy link
Contributor

@MarinPostma MarinPostma commented Jun 15, 2021

This pr implements the error handling for meilisearch.

Rather than grouping errors by types, this implementation groups them by scope, each scope enclosing errors from a scope further down, or new errors within this scope. This makes the tracking of the origins of errors easier , and error handling easier at the module level.

All errors that are eventually returned to the user implement the Into<ResponseError> trait. ReponseError in turn implements the ErrorCode trait from meilisearch-error.

Some new errors have been introduced with the new engine for which we haven't defined error codes yet. It has been decided with @gmourier that those would return the internal-error code until the correct error code is specified.

@MarinPostma MarinPostma force-pushed the error-handling branch 2 times, most recently from 82fa049 to 74f8935 Compare June 17, 2021 12:38
@MarinPostma MarinPostma marked this pull request as ready for review June 21, 2021 11:58
@MarinPostma MarinPostma requested review from curquiza and irevoire June 21, 2021 11:58
irevoire
irevoire previously approved these changes Jun 21, 2021
Copy link
Member

@irevoire irevoire left a comment

Choose a reason for hiding this comment

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

best PR I've seen so far 😎

Copy link
Member

@curquiza curquiza left a comment

Choose a reason for hiding this comment

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

Can you return a content-type: application/json when returning an error?

Copy link
Member

@curquiza curquiza left a comment

Choose a reason for hiding this comment

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

When pushing a badly formatted JSON document (for example the extra coma at the end of the line) I got a bad_request in v0.20.0 and now an internal. Can we change this?

Copy link
Member

@curquiza curquiza left a comment

Choose a reason for hiding this comment

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

Can we remove the todo from the update answer?

Capture d’écran 2021-06-21 à 14 44 06

@curquiza
Copy link
Member

curquiza commented Jun 21, 2021

Related to my previous comment: missing primary key has already an error code -> https://docs.meilisearch.com/errors/#missing_primary_key

@MarinPostma
Copy link
Contributor Author

@curquiza yeah sorry this part is unrelated to error codes, i just forgot to change the error type for updates 🤦

@curquiza
Copy link
Member

Another feedback. Before there were two errors:

  • missing_primary_key -> there is no document in MeiliSearch, you try to insert document, but MeilISearch cannot find the primary key.
  • missing_document_id -> there is already a defined primary key but the documents you try to push do not contain it.

Now, I only get the missing_primay_key error when doing my tests.

@curquiza
Copy link
Member

When trying:

{
    "q": "",
    "filters": "genre = fantasy"
}

I get an internal error, but an error code already exists for this: bad_request

@MarinPostma
Copy link
Contributor Author

MarinPostma commented Jun 21, 2021

Another feedback. Before there were two errors:

missing_primary_key -> there is no document in MeiliSearch, you try to insert document, but MeilISearch cannot find the primary key.
missing_document_id -> there is already a defined primary key but the documents you try to push do not contain it.
Now, I only get the missing_primay_key error when doing my tests.

I'm not the one returning this error, milli is, @ManyTheFish @Kerollmops, this one is one you guys ;)

@curquiza I think the rest is fixed.

@curquiza
Copy link
Member

Can we change the message to the v0.20 one?

Transplant
Capture d’écran 2021-06-22 à 12 18 47

MeiliSearch v0.20
Capture d’écran 2021-06-22 à 12 30 37

@curquiza
Copy link
Member

Same for index not found:
Transplant
Capture d’écran 2021-06-22 à 12 33 34

Meilisearch v0.20
Capture d’écran 2021-06-22 à 12 32 52

@irevoire
Copy link
Member

irevoire commented Jun 22, 2021

When looking for a non-existing update, don't get the same message as before:
Meilisearch: "Update 4 not found"
Transplant: "error with update: update 4 doesn't exist."


When doing a search with a bad field name the message also slightly vary:
Meilisearch:

"Invalid JSON: unknown field `truc`, expected one of `q`, `offset`, `limit`, `attributesToRetrieve`, `attributesToCrop`, `cropLength`, `attributesToHighlight`, `filters`, `matches`, `facetFilters`, `facetsDistribution` at line 1 column 22"

Transplant:

"Json deserialize error: unknown field `truc`, expected one of `q`, `offset`, `limit`, `attributesToRetrieve`, `attributesToCrop`, `cropLength`, `attributesToHighlight`, `matches`, `filter`, `facetDistributions` at line 1 column 22"

Feel free to close this comment if this is not an issue!

@irevoire

This comment has been minimized.

@irevoire

This comment has been minimized.

@curquiza
Copy link
Member

Checked with @MarinPostma! Issues will be open for the message errors and will be fixed for the v0.21.0

@MarinPostma
Copy link
Contributor Author

bors merge

@bors
Copy link
Contributor

bors bot commented Jun 22, 2021

@bors bors bot merged commit 25af262 into main Jun 22, 2021
@bors bors bot deleted the error-handling branch June 22, 2021 13:39
@curquiza curquiza mentioned this pull request Jun 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants