[Bug?]: send() is not transformed
- 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
send() is not transformed and results in an error.
For example:
```var CloudWatchLogs = require('aws-sdk/clients/cloudwatchlogs');
var cloudwatchlogs = new CloudWatchLogs();
var Request = cloudwatchlogs.putLogEvents();
Request.send();
console.log("got past sent");
```
executes without error in AWS SDK for JavaScript v2 .
After running aws-sdk-js-codemod, it is transformed into:
```const { CloudWatchLogs } = require("@aws-sdk/client-cloudwatch-logs");
var cloudwatchlogs = new CloudWatchLogs();
var Request = cloudwatchlogs.putLogEvents();
Request.send();
console.log("got past sent");
```
When the transformed code is executed, it results in:
```/home/cloudshell-user/test7.js:4
Request.send();
^
TypeError: Request.send is not a function
at Object. (/home/cloudshell-user/test7.js:4:9)
at Module._compile (node:internal/modules/cjs/loader:1521:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1623:10)
at Module.load (node:internal/modules/cjs/loader:1266:32)
at Module._load (node:internal/modules/cjs/loader:1091:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:164:12)
at node:internal/main/run_main_module:28:49
Node.js v20.20.2
```
Please fix.
### Steps to reproduce
```var CloudWatchLogs = require('aws-sdk/clients/cloudwatchlogs');
var cloudwatchlogs = new CloudWatchLogs();
var Request = cloudwatchlogs.putLogEvents();
Request.send();
console.log("got past sent");
```
### Observed behavior
After running aws-sdk-js-codemod, it is transformed into:
```const { CloudWatchLogs } = require("@aws-sdk/client-cloudwatch-logs");
var cloudwatchlogs = new CloudWatchLogs();
var Request = cloudwatchlogs.putLogEvents();
Request.send();
console.log("got past sent");
```
When the transformed code is executed, it results in:
```/home/cloudshell-user/test7.js:4
Request.send();
^
TypeError: Request.send is not a function
at Object. (/home/cloudshell-user/test7.js:4:9)
at Module._compile (node:internal/modules/cjs/loader:1521:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1623:10)
at Module.load (node:internal/modules/cjs/loader:1266:32)
at Module._load (node:internal/modules/cjs/loader:1091:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:164:12)
at node:internal/main/run_main_module:28:49
Node.js v20.20.2
```
### Expected behavior
Transformed code executes successfully as the original code did with AWS SDK for JavaScript v2 and has the same behavior as the original code.
### Environment
```shell
aws-sdk-js-codemod: 3.0.2
- jscodeshift: 17.3.0
- recast: 0.23.11
```
### Additional context
_No response_
Contributor guide
Research direction
Start by running the supplied reproduction through aws-sdk-js-codemod 3.0.2 and trace how Request.send() is handled during transformation. Compare the generated AWS SDK v3 code with the documented v2 behavior; done means the transformed example executes successfully and preserves the original behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, javascript, node.js, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100