-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[BUG] Different error response in delete API #14805
Comments
I can't find the info on error responses for the APIs in the API spec or the API documentation. Or am i missing something? |
[Indexing Triage Meeting 07/22] This seems a fairly reasonable ask to align the error response across APIs.
@imvtsl Could you help checking on these aspects? |
As discussed in the meeting today, I have created issues in Documentation and API specification repositories for missing error responses. |
Is a breaking change acceptable if it's part of a major release (e.g., 3.0)? If not, we could implement API versioning (e.g., /v2/sample-index/_doc/1) to maintain the current API version's behavior.
@peternied did suggest something similar to this approach for backwards compatibility. New fields in delete API error response would be error block, something like below:
Thanks @peternied for the suggestion. This approach maintains backward compatibility but results in non-uniform JSON across APIs. Besides the "error" key, all other keys are specific to individual APIs, which could undermine the goal of having a standardized error response format. Alternatively, can we nest those into a free form object or a string? See below.
We could introduce a "message" key to handle additional fields in a free-form object or string. When required, API specific clients would parse this to get client specific info. So, the json response would look something like below.
Because "message" is a free form object, clients on a high level have to define one generic error response object for all APIs (error, message and status keys). Specific API clients would override this message object and parse it in the API specific way. This approach does break backwards compatibility, but leads to generalization. Thoughts, @peternied , @mgodwan , @dblock ? |
I debugged the code to understand the flow of the delete API call. I have summarized it briefly: InternalEngine returns I compared it with the code flow in case create document request fails. When a create document request fails, To address this issue, we could modify the delete handling to return resultType set to FAILED and failure set to |
On a different note, do we have any strict timelines to work on the issues. We triaged it about two weeks ago, and I was away for some time, so I could only recently begin working on it. I wanted to check if we are okay? |
There are no expectations of anyone doing any work or timelines as with most open source. |
Describe the bug
Response body of failures on create index API, delete index API, create document API, etc follow a consistent format.
However, response body of failure in delete document API is different. It is similar to the response body of Success scenario. See all responses below.
I believe the best practice is for error responses to be standardized across all APIs. It makes error handling for the client easier. See this issue.
Sample Responses
Index create failed
Index delete failed
Document create failed
Document delete failed
The above follows the same format as Success scenario:
Document delete success
Related component
Indexing
To Reproduce
curl -X PUT localhost:9200/sample-index
curl -X DELETE localhost:9200/sample-index/_doc/1
Expected behavior
Error response format in case of delete document failure should be same as failure in other APIs.
Additional Details
No response
The text was updated successfully, but these errors were encountered: