[Rest Api Compatibility] content-type headers are not vendor specific when exception is returned #92658
Labels
>bug
:Core/Infra/REST API
REST infrastructure and utilities
Team:Core/Infra
Meta label for core/infra team
Elasticsearch Version
8.5
Installed Plugins
No response
Java Version
bundled
OS Version
macos
Problem Description
when an exception like 404 not found is returned a response content type is not vendor specific even though the Accept header was vnd specific on a request.
Steps to Reproduce
send a request to a non existing index
curl -k --request GET -u elastic:f2RROKkV5m_2P+VCMYdU --url https://localhost:9200/missing/_search --header 'Content-Type: application/vnd.elasticsearch+json;compatible-with=8' --header 'Accept: application/vnd.elasticsearch+json;compatible-with=8' -v
response
< HTTP/1.1 404 Not Found
< X-elastic-product: Elasticsearch
< content-type: application/json;charset=utf-8
< content-length: 371
<
{"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index [missing]","resource.type":"index_or_alias","resource.id":"missing","index_uuid":"na","index":"missing"}],"type":"index_not_found_exception","reason":"no such index [missing]","resource.type":"index_or_alias","resource.id":"missing","index_uuid":"na","index":"missing"},"status":404}%
I think this is due to error handling was not implemented fully with rest api compatibility project.
the fix should change
elasticsearch/server/src/main/java/org/elasticsearch/rest/RestResponse.java
Line 125 in 06d4ef7
Logs (if relevant)
No response
The text was updated successfully, but these errors were encountered: