Skip to content

HDDS-15607. Return x-amz-meta-* user-defined object metadata on S3 GetObject#10785

Merged
chungen0126 merged 1 commit into
apache:masterfrom
Gargi-jais11:HDDS-15607
Jul 21, 2026
Merged

HDDS-15607. Return x-amz-meta-* user-defined object metadata on S3 GetObject#10785
chungen0126 merged 1 commit into
apache:masterfrom
Gargi-jais11:HDDS-15607

Conversation

@Gargi-jais11

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

s3-tests test_object_set_get_metadata_* fail with KeyError:'meta1'.
PutObject stores custom metadata via getCustomMetadataFromHeaders(), and HeadObject returns it via addCustomMetadataHeaders(), but GetObject does not."

  • test_object_set_get_metadata_none_to_good
  • test_object_set_get_metadata_none_to_empty
  • test_object_set_get_metadata_overwrite_to_empty
  • test_object_set_get_unicode_metadata

Fix:
AddedaddCustomMetadataHeaders() to the GET response builder.

What is the link to the Apache JIRA

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

How was this patch tested?

Added IT and UT.
Before Fix:

bash-5.1$ aws s3api put-object \
  --bucket metatest \
  --key foo \
  --body /tmp/bar \
  --metadata meta1=mymeta \
  --endpoint-url http://s3g:9878
{
    "ETag": "\"c157a79031e1c40f85931829bc5fc552\""
}
bash-5.1$ aws s3api get-object \
  --bucket metatest \
  --key foo \
  /tmp/out \
  --endpoint-url http://s3g:9878 \
  --query 'Metadata'
                <------------------------- Didn't return the metadata tag
  
bash-5.1$ aws s3api put-object \
  --bucket metatest \
  --key foo2 \
  --body /tmp/bar \
  --metadata meta1= \
  --endpoint-url http://s3g:9878
{
    "ETag": "\"c157a79031e1c40f85931829bc5fc552\""
}
bash-5.1$ aws s3api get-object \
  --bucket metatest \
  --key foo2 \
  /tmp/out2 \
  --endpoint-url http://s3g:9878 \
  --query 'Metadata'
                 <------------------------- Didn't return the metadata tag

After Fix:

bash-5.1$ aws s3api put-object \
  --bucket metatest \
  --key foo \
  --body /tmp/bar \
  --metadata meta1=mymeta \
  --endpoint-url http://s3g:9878/
{
    "ETag": "\"c157a79031e1c40f85931829bc5fc552\""
}
bash-5.1$ aws s3api get-object \
  --bucket metatest \
  --key foo \
  /tmp/out \
  --endpoint-url http://s3g:9878/ \
  --query 'Metadata'
{
    "meta1": "mymeta"
}
bash-5.1$ aws s3api put-object \
  --bucket metatest \
  --key foo2 \
  --body /tmp/bar \
  --metadata meta1= \
  --endpoint-url http://s3g:9878/
{
    "ETag": "\"c157a79031e1c40f85931829bc5fc552\""
}
bash-5.1$ aws s3api get-object \
  --bucket metatest \
  --key foo2 \
  /tmp/out2 \
  --endpoint-url http://s3g:9878/ \
  --query 'Metadata'
{
    "meta1": ""
}

@ivandika3
ivandika3 requested a review from xichen01 July 17, 2026 04:41
@Gargi-jais11
Gargi-jais11 marked this pull request as ready for review July 17, 2026 04:43
@Gargi-jais11 Gargi-jais11 added the s3 S3 Gateway label Jul 17, 2026

@rich7420 rich7420 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.

LGTM!

@ivandika3 ivandika3 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.

@Gargi-jais11 Thanks for the patch. LGTM +1.

It's better to also add integration test, but I'm OK as is.

@ArafatKhan2198 ArafatKhan2198 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.

LGTM. The fix is good!

Non-blocking suggestion: please consider extending the test to cover empty and Unicode metadata values, since these are explicitly listed among the failing s3-tests. The PR description also mentions an integration test, but this patch currently appears to add only a unit test.

@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

@chungen0126
chungen0126 merged commit 5bfa452 into apache:master Jul 21, 2026
59 checks passed
@chungen0126

Copy link
Copy Markdown
Contributor

Thanks @Gargi-jais11 for working on this, @ivandika3 @ArafatKhan2198 for the review.

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.

5 participants