Node AWS SDK v3 not parsing Cloudflare response

I have the following code in aws-sdk:

const results = await s3.send(new ListBucketsCommand({}));

This is producing an error:

9664 |         parser.addEntity("#10", "\n");
9665 |         const parsedObj = parser.parse(encoded);
9666 |         const textNodeName = "#text";
9667 |         const key = Object.keys(parsedObj)[0];
9668 |         const parsedObjToReturn = parsedObj[key];
9669 |         if (parsedObjToReturn[textNodeName]) {
               ^
TypeError: undefined is not an object (evaluating 'parsedObjToReturn[textNodeName]')
  Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.
      at /node_modules/@aws-sdk/client-s3/dist-cjs/protocols/Aws_restXml.js:9669:12
      at processTicksAndRejections (:1:2602)

Printing error.$response as suggested does not provide any useful information (I wanted to see if it included the raw response body, but as far as I can tell it does not). I have also confirmed that my key and secret work correctly because the AWS cli is able to issue this request (as is aws4fetch).

I’ll cross-file this on aws-sdk, but is there a way to diagnose if this is on the Cloudflare side or the aws-sdk side?

Nevermind - this can be closed. Turns it out was an issue with bun, not Cloudflare or aws-sdk. Sorry for the noise!

1 Like