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

RestXML PUT Requests Failing #219

Open
mattBrzezinski opened this issue Oct 14, 2020 · 1 comment
Open

RestXML PUT Requests Failing #219

mattBrzezinski opened this issue Oct 14, 2020 · 1 comment
Labels

Comments

@mattBrzezinski
Copy link
Member

mattBrzezinski commented Oct 14, 2020

High-level S3 put_bucket_versioning is currently broken.

AWS.jl/src/services/s3.jl

Lines 1396 to 1397 in 9255fd4

put_bucket_versioning(Bucket, VersioningConfiguration; aws_config::AWSConfig=global_aws_config()) = s3("PUT", "/$(Bucket)?versioning", Dict{String, Any}("VersioningConfiguration"=>VersioningConfiguration); aws_config=aws_config)
put_bucket_versioning(Bucket, VersioningConfiguration, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = s3("PUT", "/$(Bucket)?versioning", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("VersioningConfiguration"=>VersioningConfiguration), args)); aws_config=aws_config)

We are passing the VersionConfiguration as an argument named itself. However, this needs to be actually passed in as the body:

Current:

using AWS.AWSServices: s3
bucket = "test-bucket"
versioning_config = """
        <VersioningConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
            <Status>Enabled</Status>
        </VersioningConfiguration>
"""

s3("PUT", "/$(bucket)?versioning", Dict("VersioningConfiguration"=>versioning_config))

> ERROR: AWS.AWSExceptions.AWSException("MissingRequestBodyError", "Request Body is empty",

What we want:

using AWS.AWSServices: s3
bucket = "test-bucket"
versioning_config = """
        <VersioningConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
            <Status>Enabled</Status>
        </VersioningConfiguration>
"""

s3("PUT", "/$(bucket)?versioning", Dict("body"=>versioning_config))

Looks like putting tags for a bucket is in a similar situation:

AWS.jl/src/services/s3.jl

Lines 1378 to 1379 in 9255fd4

put_bucket_tagging(Bucket, Tagging; aws_config::AWSConfig=global_aws_config()) = s3("PUT", "/$(Bucket)?tagging", Dict{String, Any}("Tagging"=>Tagging); aws_config=aws_config)
put_bucket_tagging(Bucket, Tagging, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = s3("PUT", "/$(Bucket)?tagging", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("Tagging"=>Tagging), args)); aws_config=aws_config)

Failing:

s3("PUT", "/$(bucket)?tagging", Dict("Tagging"=>tags); aws_config=aws, kwargs...)

Succeeding:

s3("PUT", "/$(bucket)?tagging", Dict("body"=>tags); aws_config=aws, kwargs...)
@mattBrzezinski mattBrzezinski changed the title High-level S3 put_bucket_versioning broken RestXML PUT Requests Failing Oct 14, 2020
@mattBrzezinski
Copy link
Member Author

Looking at the aws-sdk-js for the PutBucketVersioningRequest there is no obvious clues that these should be in the body.

"PutBucketVersioningRequest": {
      "type": "structure",
      "required": [
        "Bucket",
        "VersioningConfiguration"
      ],
      "members": {
        "Bucket": {
          "shape": "BucketName",
          "documentation": "<p>The bucket name.</p>",
          "location": "uri",
          "locationName": "Bucket"
        },
        "ContentMD5": {
          "shape": "ContentMD5",
          "documentation": "<p>&gt;The base64-encoded 128-bit MD5 digest of the data. You must use this header as a message integrity check to verify that the request body was not corrupted in transit. For more information, see <a href=\"http://www.ietf.org/rfc/rfc1864.txt\">RFC 1864</a>.</p>",
          "deprecated": true,
          "deprecatedMessage": "Content-MD5 header will now be automatically computed and injected in associated operation's Http request.",
          "location": "header",
          "locationName": "Content-MD5"
        },
        "MFA": {
          "shape": "MFA",
          "documentation": "<p>The concatenation of the authentication device's serial number, a space, and the value that is displayed on your authentication device.</p>",
          "location": "header",
          "locationName": "x-amz-mfa"
        },
        "VersioningConfiguration": {
          "shape": "VersioningConfiguration",
          "documentation": "<p>Container for setting the versioning state.</p>",
          "locationName": "VersioningConfiguration",
          "xmlNamespace": {
            "uri": "http://s3.amazonaws.com/doc/2006-03-01/"
          }
        },

bors bot added a commit to JuliaCloud/AWSS3.jl that referenced this issue Dec 8, 2020
107: Use AWS.jl instead of AWSCore.jl r=mattBrzezinski a=mattBrzezinski

## Overview
The purpose of this merge request is to replace [AWSCore.jl](https://github.com/JuliaCloud/AWSCore.jl) with the new shiny [AWS.jl](https://github.com/JuliaCloud/AWS.jl).

**This is a breaking change, since end users must use AWS.AWSConfig not AWSCore.AWSConfig structs**

Those with a sharp eye will notice that almost every definition uses the high-level S3 wrapper, except for a few cases. This is due to JuliaCloud/AWS.jl#219 which is preventing RESTXML (protocol which S3 uses) to make PUT requests with body data properly. This should not be a blocking issue, as we can convert to the high-level functions when the issue is resolved.

Co-authored-by: Matt Brzezinski <matt.brzezinski@invenia.ca>
Co-authored-by: mattBrzezinski <matt.brzezinski@invenia.ca>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant