Skip to content

HDDS-17893. S3G should return Content-Type application/x-directory for FSO directory keys - #12147

Open
yandrey321 wants to merge 2 commits into
apache:masterfrom
yandrey321:HDDS-17893
Open

yandrey321 wants to merge 2 commits into
apache:masterfrom
yandrey321:HDDS-17893

Conversation

@yandrey321

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Problem

In FSO buckets, S3 Gateway exposes every directory, including implicit parents, as a dir/ object (HDDS-7922).
HEAD and GET on it return 200 with Content-Type: binary/octet-stream, length 0 and no ETag, so it looks like an
empty file. Clients that recognize directories by the application/x-directory marker, such as Flink's Presto-based
S3 filesystem (s3p://), therefore treat these directories as files. Restoring a Flink savepoint stored in an FSO
bucket fails with NoSuchKey.

Implementation idea

ObjectEndpoint.contentTypeOf() now returns application/x-directory when the key is not a file
(!key.isFile()). HEAD and GET both get their Content-Type from this helper, so both responses change.

Key decisions

  • The directory check uses OzoneKey.isFile(), the same signal EndpointBase.validateFileKey already uses.
    The OM sets it to false only for FSO directories and forces it to true for every OBS and legacy key.
  • A directory always reports application/x-directory, even if Content-Type metadata is stored on it. This gives
    clients one consistent signal, including for implicit parent directories that have no metadata.
  • The response-content-type query parameter still overrides the value on GET, as for any other object.
  • There is no config flag. S3A doesn't use Content-Type to detect directories and writes this marker itself, so it is
    unaffected.

Side effects

  • HEAD and GET on FSO directory keys return a different Content-Type. Files, OBS and legacy buckets are unchanged.
  • Listings are unchanged, because ListObjects responses carry no Content-Type.
  • No protocol or OM change. The isFile flag arrived with the getKeyInfo OM call that S3G uses (HDDS-7419), so
    every OM that answers that call sets it.

Co-authored-by: Claude Opus 5.5 noreply@anthropic.com

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-17893

How was this patch tested?

Unit + integration tests.

…r FSO directory keys

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the s3 S3 Gateway label Nov 24, 2026

@chungen0126 chungen0126 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 LGTM

@yandrey321
yandrey321 marked this pull request as ready for review December 1, 2026 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

s3 S3 Gateway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants