Description
Is your feature request related to a problem? Please describe.
Opensearch has many different user API endpoints. Some of them behave similar and some doesn't.
During the refactoring of the opensearch-go lib, I notices that 404 response bodys are different between API endpoints.
Examples for some get requests.
GET test
{
"error": {
"root_cause": [
{
"type": "index_not_found_exception",
"reason": "no such index [test]",
"index": "test",
"resource.id": "test",
"resource.type": "index_or_alias",
"index_uuid": "_na_"
}
],
"type": "index_not_found_exception",
"reason": "no such index [test]",
"index": "test",
"resource.id": "test",
"resource.type": "index_or_alias",
"index_uuid": "_na_"
},
"status": 404
}
GET _index_template/test
{
"error": {
"root_cause": [
{
"type": "resource_not_found_exception",
"reason": "index template matching [test] not found"
}
],
"type": "resource_not_found_exception",
"reason": "index template matching [test] not found"
},
"status": 404
}
GET _scripts/test
{
"_id": "test",
"found": false
}
GET _template/test
{}
GET _ingest/pipeline/test
{}
GET test/_explain/3
{"query":{"term":{"foo":{"value":"bar"}}}}
{
"_index": "test",
"_id": "3",
"matched": false
}
Describe the solution you'd like
I would like to see a response similar to 404 responses from index
or _index_templates
.
{
"error": {
"root_cause": [
{
"type": "resource_not_found_exception",
"reason": "<resource> matching [test] not found"
}
],
"type": "resource_not_found_exception",
"reason": "<resource> matching [test] not found"
},
"status": 404
}
Describe alternatives you've considered
Depending on the endpoint it would also be an option to return a 200 with a body containing no results like the _nodes
endpoint does. This would for example work for the _index_template
and _component_template
as they return an array of templates.
GET _nodes/test
{
"_nodes": {
"total": 0,
"successful": 0,
"failed": 0
},
"cluster_name": "fsn1-staging-opensearch1",
"nodes": {}
}
Additional context
This is a bit in relation to opensearch-project/opensearch-plugins#215 as it is about errors but for plugins. AFAIK Opensearch has its standard way for errors but not one for when to return it.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status