aws / aws/aws-sdk-js-codemod

[Bug]: When S3.GetObject is called and Body is processed, the equivalent v3 mixins are not added

Open
#789 1 comment 2 reactions 0 assignees View on GitHub
bug p2
Dominant language
TypeScript
Stars
89
Forks
13
Avg merge
9h 59m
Merged PRs (30d)
1

Description

### Self-service

- [ ] I'd be willing to implement a fix

### Describe the bug

When S3.GetObject is called and Body is processed, the equivalent v3 mixins are not added

### Steps to reproduce

```js
import AWS from "aws-sdk";

const client = new AWS.S3();
const params = {
Bucket: "my-bucket",
Key: "my-key",
};
const response = await client.getObject(params).promise();

const data = response.Body;
```

### Observed behavior

The `data` in the transformed code is a Readable Stream and not a buffer.

```js
import { S3 } from "@aws-sdk/client-s3";

const client = new S3();
const params = {
Bucket: "my-bucket",
Key: "my-key",
};
const response = await client.getObject(params);

const data = response.Body;
```

### Expected behavior

The Body needs to be transformed from Readable Stream to Buffer.

```js
import { S3 } from "@aws-sdk/client-s3";

const client = new S3();
const params = {
Bucket: "my-bucket",
Key: "my-key",
};
const response = await client.getObject(params);

const data = Buffer.from(await response.Body.transformToByteArray());
```

### Environment

```shell
aws-sdk-js-codemod: 1.0.5
- jscodeshift: 0.15.2
- recast: 0.23.4
```

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Locate the S3.GetObject handling in the codemod and its regression tests, then start by reproducing the issue with the example in this report. Done means the transformed response.Body uses the expected Buffer conversion rather than remaining a readable stream, with the regression covered by the existing test suite.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, javascript, typescript
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.