-
Notifications
You must be signed in to change notification settings - Fork 86
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
JSON decode error on Nginx 504 Gateway Time-out from Meilisearch Cloud #990
Comments
Indeed, there is a premise in the way the package is managing such errors. Here meilisearch-python/meilisearch/errors.py Line 28 in 127b478
And here
We can see that every errors are intended to be To me, it looks like the error management need to handle differently errors that are returned by There is multiple way to handle such use case, the best one to me is introduced by the RFC 9457 but it's not commonly adopted by systems we are working with today so it doesn't look like a valid option here (maybe in 10 years 😅). Another solution would be to being able to differentiate We can also just Regardless the solution you chose to implement, I would be pleased to do it myself in this repository :) |
I have not had time to really look at this, but a simple solution could potentially be changing if request.text:
json_data = json.loads(request.text)
self.message = json_data.get("message")
self.code = json_data.get("code")
self.link = json_data.get("link")
self.type = json_data.get("type") to if request.content:
json_data = request.json()
self.message = json_data.get("message")
self.code = json_data.get("code")
self.link = json_data.get("link")
self.type = json_data.get("type") This is untested so I'm not sure if it would solve the issue, but maybe. |
If the data is not JSON decodable The main point for this issue is to:
|
Hello here, I'm discussing with Meilisearch team. You problem might not be related to the Python SDK (even if changes can always be applied, but let's try to mitigate the problem first). We had issues with v1.8.0, v1.8.1 and v1.8.2: soft lock and memory leaks we solved in v1.8.3. As far as we know, you are using v1.8.1 on the Cloud, let me know if I'm wrong. |
@mde-pach I put in a fix for this in another library here. Do you want to try to do something similar? The idea is if the response isn't JSON we know the error didn't come from Meilisearch so raise the error as is rather than trying to process it. But as @curquiza said, this won't solve the underlying issue, only hopefully make it easier to understand what is happening. |
Hi folks! I was discussing with @curquiza and the team that we should change the content types of these errors in our Meilisearch Cloud infra. You got the parsing error because the message comes from our proxy layer, not the meilisearch instance, which is HTML. That's why they are so different. So, we could add special handling like @sanders41 in his SDK, but ideally, everything should be JSON in the first place, so I don't think it is worth it until we change on our side first. |
Make sense to me :) |
@sauloperez if upgrading Meilisearch doesn't solve the issue, you could add tenacity to your functions that are getting error responses to have them retry. It would be a work around and not a real fix, but might help. |
thanks everyone, we'll definitely go with tenacity or backoff, while we also try to upgrade to v1.9, which has failed so far. |
Description
When receiving a 504 Gateway timeout on a call to
index.update_documents
, the SDK raises aJSONDecodeError
instead of the expectedMeilisearchApiError
. You can see the stacktrace we found in our Sentry account in the Screenshots or Logs section below.Note we're using Meilisearch Cloud so the underlying issue is related to Meilisearch's Cloud unresponsiveness.
Expected behavior
One would expect to get a meaningful
MeilisearchApiError
so we can retry the operation at a later time, or any other fault-tolerance mechanism.Current behavior
A
JSONDecodeError
was raised, which initially makes you think there's a problem on the way the documents are serialized.Screenshots or Logs
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: