aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
3.12k stars 579 forks source link

client-s3 :: Setting `AccessControlPolicy` via `putObjectAcl` throws a MalformedACLError #2267

Closed philiiiiiipp closed 2 years ago

philiiiiiipp commented 3 years ago

Describe the bug

I tried setting an AccessControlPolicy using the putObjectAcl but it seems to throw a MalformedACLError

Error [MalformedACLError]: The XML you provided was not well-formed or did not validate against our published schema
    at /var/task/functions/resolver/webpack:/Users/philipp/node/dev/dh/sfa-api/node_modules/@aws-sdk/client-s3/dist/es/protocols/Aws_restXml.js:8733:1
    at step (/var/task/functions/resolver/webpack:/Users/philipp/node/dev/dh/sfa-api/node_modules/@aws-sdk/client-s3/node_modules/tslib/tslib.es6.js:102:1)
    at Object.next (/var/task/functions/resolver/webpack:/Users/philipp/node/dev/dh/sfa-api/node_modules/@aws-sdk/client-s3/node_modules/tslib/tslib.es6.js:83:1)
    at fulfilled (/var/task/functions/resolver/webpack:/Users/philipp/node/dev/dh/sfa-api/node_modules/@aws-sdk/client-s3/node_modules/tslib/tslib.es6.js:73:1)
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  Code: 'MalformedACLError',
  RequestId: 'XXX',
  HostId: 'XXX,
  '$fault': 'client',
  '$metadata': {
    httpStatusCode: 400,
    requestId: undefined,
    extendedRequestId: 'XXX',
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  }
} 

My request is

putObjectAcl({
    Bucket: 'somebucket',
    Key: 'somekey',
    AccessControlPolicy: {
      Grants: [
        {
          Grantee: {
            DisplayName: 'somename',
            ID: 'someid',
            Type: 'CanonicalUser',
          },
          Permission: 'FULL_CONTROL',
        },
      ],
      Owner: {
            DisplayName: 'somename',
            ID: 'someid',
      },
    },
  });

When trying the same request but setting an ACL instead, the request works just fine.

putObjectAcl({
    ACL: 'public-read',
    Bucket: 'somebucket',
    Key: 'somekey',
  });

Your environment

SDK version number

├── @aws-sdk/client-s3@3.12.0 
└─┬ @aws-sdk/lib-storage@3.12.0
  └── @aws-sdk/client-s3@3.12.0 

Is the issue in the browser/Node.js/ReactNative?

Node.js

Details of the browser/Node.js/ReactNative version

It runs inside a lambda function set to nodejs12.x

ajredniwja commented 3 years ago

HI @philiiiiiipp thanks for opening this issue, I was able to reproduce this, both in V2 and V3 with root cause still unknown, I have reached out to S3 team to have a look.

kgwong-uc commented 3 years ago

This seem to be fixed since 3.18.0

github-actions[bot] commented 2 years ago

Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue.

github-actions[bot] commented 2 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.