3 Answers
- Newest
- Most votes
- Most comments
0
You have ":". You want "=". Take a look at https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3api/put-bucket-tagging.html where you will see the example: TagSet=[{Key=string,Value=string},{Key=string,Value=string}]
So yours should be: const putBucketTaggingCommand = new PutBucketTaggingCommand({ Bucket : lambdaFunctionsBucket, Tagging : { TagSet=[{Key=siteTag,Value=''}] } })
answered a month ago
0
It looks like the issue was a the key variable (siteTag
) was undefined
. It would be nice to have a more helpful error message, but there it is. (I'd printed the value, but then changed the implementation and introduced the bug.)
answered a month ago
0
From the details you've provided, a couple of things stand out:
- Undefined siteTag Value: You mentioned that siteTag was possibly undefined at the time of the operation. This could certainly lead to a malformed request, as S3 expects each tag in the TagSet to have both a Key and a Value. An undefined Key or Value would result in invalid XML being generated by the SDK.
- XML Validation: The error message specifically mentions that the XML was not well-formed or did not validate against S3's published schema. This further supports the idea that the issue is related to the content of the TagSet. Given this, here are a few steps you can take to troubleshoot and potentially fix the issue:
- Ensure Defined Tags: Make sure that both Key and Value for each tag in the TagSet are defined and not empty strings. If you intend to have an empty value for a tag, ensure that the Value is explicitly set to an empty string ('') and not undefined.
- Check Tag Format: Verify that the format of your tags complies with S3's restrictions. For example, tag keys and values have certain allowed characters and size limitations.
- Log the Request: Temporarily add logging to your code to print the final putBucketTaggingCommand object just before it's sent. This can help you visually inspect the request to ensure it's structured correctly.
- Minimal Example: Try creating a minimal example with hardcoded values for Bucket, Key, and Value that you know are valid. If this works, then gradually reintroduce the dynamic aspects of your code to identify where the issue lies.
- SDK Documentation: Double-check the SDK documentation for PutBucketTaggingCommand to ensure that all parameters are being used correctly and that there haven't been any recent changes to the API or the way it's called.
Relevant content
- asked 5 years ago
- asked 10 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
Thanks for the response, but I don't think that's right. I'm using Javascript SDK v3, and what you suggest would be invalid Javascript syntax.