Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put object tagging does not work with aws cli #1978

Closed
iw108 opened this issue Jul 12, 2024 · 8 comments · Fixed by #2003
Closed

Put object tagging does not work with aws cli #1978

iw108 opened this issue Jul 12, 2024 · 8 comments · Fixed by #2003
Assignees
Labels

Comments

@iw108
Copy link

iw108 commented Jul 12, 2024

Hi,

Great work with the project, it's very useful!

I am currently trying to set some tags (PutObjectTagging) on an object, however the server always returns a 400 response. Do you have any ideas what's causing this? I am able to retrieve tags without a problem.

Thanks in advance!

@afranken afranken self-assigned this Jul 12, 2024
@afranken
Copy link
Member

Hi,
thanks for using S3Mock :)

We have two integration tests for setting and retrieving tags on objects using the V1 and V2 AWS SDKs for Java:
https://github.com/adobe/S3Mock/blob/main/integration-tests/src/test/kotlin/com/adobe/testing/s3mock/its/ObjectTaggingV1IT.kt
https://github.com/adobe/S3Mock/blob/main/integration-tests/src/test/kotlin/com/adobe/testing/s3mock/its/ObjectTaggingV2IT.kt

How are you accessing the API?

Cheers,
Arne

@iw108
Copy link
Author

iw108 commented Jul 12, 2024

Hi,

Thanks for getting back in touch! I've tried with the aws cli and also aiobotocore, e.g.

touch example.txt

aws s3api create-bucket \
    --bucket x \
    --endpoint http://localhost:9090

aws s3api put-object \
    --body example.txt \
    --bucket x \
    --key y.txt \
    --endpoint http://localhost:9090

# This works
aws s3api get-object-tagging \
    --bucket x \
    --key y.txt \
    --endpoint http://localhost:9090

# This doesn't
aws s3api put-object-tagging \
    --tagging '{"TagSet": [{"Key": "a", "Value": "b"}]' \
    --bucket x \
    --key y.txt \
    --endpoint http://localhost:9090

@afranken
Copy link
Member

not sure how aiobotocore produces the payload, but your AWS CLI payload is not valid JSON:
'{"TagSet": [{"Key": "a", "Value": "b"}]'

you're missing the closing curly bracket. The payload should be:
'{"TagSet": [{"Key": "a", "Value": "b"}]'}

@iw108
Copy link
Author

iw108 commented Jul 12, 2024

Sorry about the typo above, with the correct payload the server returns a 400 error

@afranken
Copy link
Member

ok, I could reproduce this locally. The API strictly lists XML as the only valid input for this API (AFAIK, this is the case for all S3 APIs):
https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectTagging.html

The AWS CLI does not set application/xml as the content-type, which S3Mock currently enforces for all APIs accepting XML as input.

The Java SDKs always set the correct header, that's why the tests are passing.

@iw108
Copy link
Author

iw108 commented Jul 15, 2024

Thanks for the explanation!

Is there any way the server side content-type checks can be relaxed?

@afranken
Copy link
Member

sure, that should be possible.
I'll look into it next week. :)

@afranken afranken changed the title Setting tags Put object tagging does not work with aws cli Jul 24, 2024
@afranken afranken added the bug label Jul 24, 2024
@afranken
Copy link
Member

@iw108 I released 3.10.0 that supports these requests. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants