Gargi-jais11 opened a new pull request, #10277:
URL: https://github.com/apache/ozone/pull/10277

   ## What changes were proposed in this pull request?
   Object tags are handled internally as a Map. When TagSet is built from map 
iteration (e.g. HashMap), the order of <Tag> elements in the XML response is 
undefined. That order can differ from the order the client sent on 
PutObjectTagging, even though keys and values are correct.
   
   Some S3 compatibility suites `test_put_modify_tags` (e.g. boto/s3tests)` 
assert response["TagSet"] == expected_tag_set `as Python lists, which requires 
same keys, values, and order.
   
   **Expected behavior**
   GetObjectTagging should return tags in a stable order. Aligning with common 
S3 behavior, tags should be ordered lexicographically by tag key 
(Unicode/string natural order).
   
   **Example**
   ```
   PutObjectTagging
   TagSet: [
    { Key: key, Value: val },
    { Key: key2, Value: val2 }
    ] 
    
   ```
   **Wrong (flaky / fails strict tests):**
   ```
   GetObjectTagging----->
   
    "TagSet": [
      {"Key":"key2","Value":"val2"},
      {"Key":"key","Value":"val"} 
     ] 
   ```
   **Correct (stable, passes strict equality when expectation is key-first):**
   ```
    "TagSet": [
   {"Key":"key","Value":"val"},
   {"Key":"key2","Value":"val2"} 
   ] 
   ```
   Emit TagSet sorted by tag key when building the GetObjectTagging response 
(e.g. sort map entries before XML).
   
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-15283
   
   ## How was this patch tested?
   
   Added UT and IT tests.
   Tested manually.
   Before fix: **test_put_modify_tags** s3 test was failing from ozone 
compatibility.
   ```
   bash-5.1$ aws s3api put-object   --bucket buck1   --key key1  --tagging 
'foo=bar&bar=val'   --endpoint-url  http://s3g:9878/
   {
       "ETag": "\"d41d8cd98f00b204e9800998ecf8427e\""
   }
   bash-5.1$ aws s3api get-object-tagging   --bucket buck1   --key key1 
--endpoint-url  http://s3g:9878/
   {
       "TagSet": [
           {
               "Key": "foo",
               "Value": "bar"
           },                                 
-------------------------------------> wrong order that's why it fails on s3 
compatibilty test
           {
               "Key": "bar",
               "Value": "val"
           }
       ]
   }
   ```
   
   After fix:
   ```
   bash-5.1$ aws s3api put-object   --bucket buck1   --key key1  --tagging 
'foo=bar&bar=bar1'   --endpoint-url  http://s3g:9878/
   {
       "ETag": "\"d41d8cd98f00b204e9800998ecf8427e\""
   }
   bash-5.1$ aws s3api get-object-tagging   --bucket buck1   --key key1 
--endpoint-url  http://s3g:9878/
   {
       "TagSet": [
           {
               "Key": "bar",
               "Value": "bar1"
           },
           {
               "Key": "foo",
               "Value": "bar"
           }
       ]
   }
   bash-5.1$ aws s3api put-object-tagging  --bucket buck1  --key key1 --tagging 
'TagSet=[{Key=test2,Value=replace},{Key=test1,Value=replace1}]' --endpoint-url 
http://s3g:9878/
   
   bash-5.1$ aws s3api get-object-tagging  --bucket buck1  --key key1 
--endpoint-url http://s3g:9878/
   {
     "TagSet": [
       {
         "Key": "test1",
         "Value": "replace1"
       },
       {
         "Key": "test2",
         "Value": "replace"
       }
     ]
   }
   ```
   


-- 
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