aws / aws-sdk

Landing page for the AWS SDKs on GitHub
https://aws.amazon.com/tools/
Other
68 stars 13 forks source link

RestoreObjectCommand Malformed XML #505

Closed ChocolateLoverRaj closed 3 months ago

ChocolateLoverRaj commented 1 year ago

Checkboxes for prior research

Describe the bug

I get this error: MalformedXML: The XML you provided was not well-formed or did not validate against our published schema The restore doesn't happen

SDK version number

@aws-sdk/package-name@version, ...

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v18.15.0

Reproduction Steps

In .env have AWS_REGION as the AWS region.

import {
  S3Client,
  RestoreObjectCommand,
  Tier
} from '@aws-sdk/client-s3'
import { config } from 'dotenv'
config()

const s3Client = new S3Client({
  region: process.env.AWS_REGION
})
await s3Client.send(new RestoreObjectCommand({
  Bucket: 'programmatically-created-bucket',
  Key: 'file.txt',
  RestoreRequest: {
    Days: 30,
    Tier: Tier.Bulk
  }
}))

Observed Behavior

Error:

/home/rajas/aws-playground/node_modules/.pnpm/@aws-sdk+smithy-client@3.296.0/node_modules/@aws-sdk/smithy-client/dist-cjs/default-error-handler.js:8
    const response = new exceptionCtor({
                     ^

MalformedXML: The XML you provided was not well-formed or did not validate against our published schema
    at throwDefaultError (/home/rajas/aws-playground/node_modules/.pnpm/@aws-sdk+smithy-client@3.296.0/node_modules/@aws-sdk/smithy-client/dist-cjs/default-error-handler.js:8:22)
    at deserializeAws_restXmlRestoreObjectCommandError (/home/rajas/aws-playground/node_modules/.pnpm/@aws-sdk+client-s3@3.299.0/node_modules/@aws-sdk/client-s3/dist-cjs/protocols/Aws_restXml.js:5975:51)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /home/rajas/aws-playground/node_modules/.pnpm/@aws-sdk+client-s3@3.299.0/node_modules/@aws-sdk/middleware-serde/dist-cjs/deserializerMiddleware.js:7:24
    at async /home/rajas/aws-playground/node_modules/.pnpm/@aws-sdk+client-s3@3.299.0/node_modules/@aws-sdk/middleware-signing/dist-cjs/middleware.js:14:20
    at async /home/rajas/aws-playground/node_modules/.pnpm/@aws-sdk+client-s3@3.299.0/node_modules/@aws-sdk/middleware-retry/dist-cjs/retryMiddleware.js:27:46
    at async /home/rajas/aws-playground/node_modules/.pnpm/@aws-sdk+client-s3@3.299.0/node_modules/@aws-sdk/middleware-flexible-checksums/dist-cjs/flexibleChecksumsMiddleware.js:58:20
    at async /home/rajas/aws-playground/node_modules/.pnpm/@aws-sdk+client-s3@3.299.0/node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:7:26
    at async file:///home/rajas/aws-playground/repro.js:12:1 {
  '$fault': 'client',
  '$metadata': {
    httpStatusCode: 400,
    requestId: 'N8M7Z9KPAB9FJP3W',
    extendedRequestId: '5DHmRgSz8dv/TlHNPu2rPpRNvW+eIhSlzV1ujOIKrOn3SwzhThTKoeg5UxSnTkVZuDP9zy7VEWg=',
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  },
  Code: 'MalformedXML',
  RequestId: 'N8M7Z9KPAB9FJP3W',
  HostId: '5DHmRgSz8dv/TlHNPu2rPpRNvW+eIhSlzV1ujOIKrOn3SwzhThTKoeg5UxSnTkVZuDP9zy7VEWg='
}

Node.js v18.15.0

Expected Behavior

The restore should happen, no error.

Possible Solution

Maybe it's the logic for generating XML by the RestoreObjectCommand

Additional Information/Context

No response

RanVaknin commented 1 year ago

Hi @ChocolateLoverRaj,

I remember seeing this issue come up before but I couldn't find it.

If I remember correctly, the issue is that RestoreRequest has another place you can specify the tier in, and its specific to the glacier storage class which got me confused as well.


RestoreRequest: {
    Days: 30,
    //Tier: Tier.Bulk
    GlacierJobParameters: {
      Tier: Tier.Bulk
    }
}

Hope this actually solves your issue. Thanks, Ran~

ChocolateLoverRaj commented 1 year ago

@RanVaknin it worked. Also, when using the Description property it doesn't work.

ChocolateLoverRaj commented 1 year ago

I think that the TypeScript definitions need to be changed.

RanVaknin commented 1 year ago

Hi @ChocolateLoverRaj ,

The SDK types are all auto-generated from the API models of the all the service teams. The SDK team can't change any type definitions because they will get overwritten by the next release. Additionally changing types is not considered a backwards compatible solution and will cause customer's code to break, so this is not an option unfortunately.

Also, when using the Description property it doesn't work.

Can you tell me more about what doesn't work?

Thanks, Ran~

ChocolateLoverRaj commented 1 year ago

When including the description property, a 400 malformed xml error happens.

RanVaknin commented 1 year ago

Hi @ChocolateLoverRaj ,

Thanks for explaining, Indeed I'm also getting this error. This response is from the service, and Im guessing is this is a documentation issue. I will move this to the cross sdk repo and open an internal ticket with s3 regarding this documentation.

Thanks, Ran~

P84716714

RanVaknin commented 3 months ago

Hi there, I have received confirmation that an update of the S3 lifecycle documentation is now in the S3 team's queue. Since this is not actionable by the SDK team I'm going to go ahead and close this.

please keep an eye of documentation changes for s3.

Thanks again, Ran~

github-actions[bot] commented 3 months ago

This issue is now closed.

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.