chungen0126 opened a new pull request, #12157:
URL: https://github.com/apache/ozone/pull/12157

   ## What changes were proposed in this pull request?
   
   In FSO buckets, S3 Gateway exposes every directory, including implicit 
parents, as a `dir/` object (HDDS-7922): HEAD returns 200 and GET returns an 
empty body. The response looks like an empty file: Content-Type 
`binary/octet-stream`, length 0. The only difference is the missing ETag, which 
directory detection such as Presto's does not check.
   
   Clients that rely on the `application/x-directory` marker convention (also 
written by S3A) classify these directories as files. For example, Flink's 
Presto S3 filesystem (`s3p://`) reads a savepoint directory as a 0-byte file, 
and restore fails with NoSuchKey.
   
   This PR makes HEAD and GET return `Content-Type: application/x-directory` 
for FSO directory keys (`!key.isFile()`). Both already get their Content-Type 
from `ObjectEndpoint#contentTypeOf`, so the check is added there. OM reports 
every OBS and Legacy key as a file, so only FSO directories are affected. GET's 
`response-content-type` still takes precedence. S3A detects directories without 
checking Content-Type, so it is unaffected.
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-17893
   
   ## How was this patch tested?
   
   - `TestObjectHead#testHeadWhenKeyIsDirectoryAndKeyPathEndsWithASlash` and 
the new `TestObjectGet#testGetDirectoryReturnsDirectoryContentType` check 
`application/x-directory` for an FSO directory. Both fail without the fix.
   - New 
`TestObjectHead#testHeadFileKeyEndingWithSlashKeepsDefaultContentType`: a 
0-byte file key ending in `/` (OBS-style marker) keeps `binary/octet-stream`.
   - `ozone-s3gateway` unit tests pass locally.
   - CI: https://github.com/chungen0126/ozone/actions/runs/45533152312
   
   Generated-by: Claude Code (Claude Opus 5.5)
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to