aws / aws/aws-sdk-js-codemod

[Bug]: No transformation for getObject(params).createReadStream()

Open
#862 1 comment 0 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

No transformation for getObject(params).createReadStream()

### Steps to reproduce

```ts
import { S3 } from "aws-sdk";
import { Readable } from "stream";

const client = new S3({ region: "us-west-2" });
const response: Readable = client
.getObject({ Bucket: "my-bucket", Key: "my-key" })
.createReadStream();
```

### Observed behavior

```ts
import { S3 } from "@aws-sdk/client-s3";
import { Readable } from "stream";

const client = new S3({
region: "us-west-2"
});
const response: Readable = client
.getObject({ Bucket: "my-bucket", Key: "my-key" })
.createReadStream();
```

This is an issue since `createReadStream` does not exist on getObject in v3.

### Expected behavior

```ts
import { S3 } from "aws-sdk";
import { Readable } from "stream";

const client = new S3({ region: "us-west-2" });
const response: Readable = (await client
.getObject({ Bucket: "my-bucket", Key: "my-key" }))
.Body;
```

### Environment

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

### Additional context

* Example usage: https://github.com/Budibase/budibase/blob/c75d1bd50eb3309062d5e2ac106274fbfe508ef3/packages/server/src/integrations/s3.ts#L236-L241
* The createReadStream source code in JS SDK v2: https://github.com/aws/aws-sdk-js/blob/fcb26f8051567a2cbbfe02e4f6752e982bbfa339/lib/request.js#L568

Contributor guide

Open the contributing guide

Research direction

Start by running the codemod against the TypeScript getObject(params).createReadStream() reproducer and compare the result with the expected awaited Body form. Check the linked Budibase S3 integration and the AWS SDK v2 createReadStream source for the usage and behavior the transformation must cover; done means the example no longer emits a v3 createReadStream call.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, node.js, typescript
Domain
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.