Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Cannot read properties of undefined error when promise is called on a request #882

Open
1 task
trivikr opened this issue Jun 27, 2024 · 0 comments
Open
1 task
Labels
bug Something isn't working

Comments

@trivikr
Copy link
Member

trivikr commented Jun 27, 2024

Self-service

  • I'd be willing to implement a fix

Describe the bug

Cannot read properties of undefined error when promise is called on a request

Steps to reproduce

import AWS from "aws-sdk";

const client = new AWS.S3({ region: "us-west-2" });
const request = client.listBuckets();
await request.promise();

Observed behavior

TypeError: Cannot read properties of undefined (reading 'length')
    at removePromiseForCallExpression (/Users/trivikr/.npm/_npx/7c563efbb7515419/node_modules/aws-sdk-js-codemod/dist/transforms/v2-to-v3/apis/removePromiseForCallExpression.js:33:47)
    at NodePath.<anonymous> (/Users/trivikr/.npm/_npx/7c563efbb7515419/node_modules/aws-sdk-js-codemod/dist/transforms/v2-to-v3/apis/removePromiseCalls.js:99:85)
    at /Users/trivikr/.npm/_npx/7c563efbb7515419/node_modules/jscodeshift/dist/Collection.js:75:36
    at Array.forEach (<anonymous>)
    at Collection.forEach (/Users/trivikr/.npm/_npx/7c563efbb7515419/node_modules/jscodeshift/dist/Collection.js:74:18)
    at NodePath.<anonymous> (/Users/trivikr/.npm/_npx/7c563efbb7515419/node_modules/aws-sdk-js-codemod/dist/transforms/v2-to-v3/apis/removePromiseCalls.js:98:18)
    at /Users/trivikr/.npm/_npx/7c563efbb7515419/node_modules/jscodeshift/dist/Collection.js:75:36
    at Array.forEach (<anonymous>)
    at Collection.forEach (/Users/trivikr/.npm/_npx/7c563efbb7515419/node_modules/jscodeshift/dist/Collection.js:74:18)
    at removePromiseCalls (/Users/trivikr/.npm/_npx/7c563efbb7515419/node_modules/aws-sdk-js-codemod/dist/transforms/v2-to-v3/apis/removePromiseCalls.js:86:14)

Expected behavior

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

const client = new S3({ region: "us-west-2" });
const request = client.listBuckets();
await request;

Environment

aws-sdk-js-codemod: 2.0.0
- jscodeshift: 0.16.0
- recast: 0.23.9

Additional context

No response

@trivikr trivikr added bug Something isn't working triage Triaging bugs and removed triage Triaging bugs labels Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant