Shuo Huang created HDDS-16189:
---------------------------------

             Summary: S3 Gateway returns XML error responses with text/plain 
Content-Type
                 Key: HDDS-16189
                 URL: https://issues.apache.org/jira/browse/HDDS-16189
             Project: Apache Ozone
          Issue Type: Sub-task
            Reporter: Shuo Huang
            Assignee: Shuo Huang


h2. Problem

S3 Gateway returns S3 error responses as XML, but sets the response 
Content-Type to text/plain.

Amazon S3 REST error responses use Content-Type: application/xml. Some S3 SDKs 
therefore refuse to parse Ozone error responses as XML.

h2. Reproduction

Start an Ozone cluster with S3 Gateway, then run:

{code:bash}
curl -i http://127.0.0.1:9878/nonexistent-bucket
{code}

The response contains:

{code}
HTTP/1.1 403 Forbidden
Content-Type: text/plain;charset=utf-8
{code}

However, the response body is XML:

{code:xml}
<?xml version="1.0" encoding="UTF-8"?>
<Error>
  <Code>InvalidRequest</Code>
  <Message>...</Message>
  <Resource>NONE</Resource>
  <RequestId/>
</Error>
{code}

h2. Expected Result

The response should use:

{code}
Content-Type: application/xml
{code}

h2. Impact

MinIO SDK tests report "Non-XML response from server" because the response body 
is XML but its Content-Type is text/plain.

h2. Root Cause

OS3ExceptionMapper creates the response from an XML String without specifying 
its media type:

{code:java}
return Response.status(exception.getHttpCode())
    .entity(exception.toXml()).build();
{code}

Jersey therefore uses text/plain as the Content-Type.

h2. References

* AWS S3 error responses: 
https://docs.aws.amazon.com/AmazonS3/latest/developerguide/ErrorResponses.html
* Ozone S3 compatibility report: https://ozone.s3.peterxcli.dev/



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to