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

S3 type incompatibilities in 3.726.0/3.726.1 generate TS2345 & TS2308 errors #6796

Closed
4 tasks done
KeithGillette opened this issue Jan 12, 2025 · 8 comments
Closed
4 tasks done
Assignees
Labels
bug This issue is a bug. p2 This is a standard priority issue potential-regression Marking this issue as a potential regression to be checked by team member

Comments

@KeithGillette
Copy link

KeithGillette commented Jan 12, 2025

Checkboxes for prior research

Describe the bug

Updating a project with @aws-sdk/client-s3, @aws-sdk/s3-request-presigner, & @aws-sdk/util-create-request from 3.723.0 to 3.726.0 or 3.726.1 generates TS2345 & TS2308 errors upon running tsc.

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/[email protected], @aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v20.17.0

Reproduction Steps

  1. Using latest S3 from [email protected] (or 3.726.1) and latest createRequest from @aws-sdk/[email protected] similar to:
import { DeleteObjectsOutput, GetObjectCommand, GetObjectOutput, PutObjectOutput, S3, S3ClientConfig } from '@aws-sdk/client-s3';
import { createRequest } from '@aws-sdk/util-create-request';

const s3Client = new S3({
	credentials: {
		accessKeyId: accessTokenResponse.key,
		secretAccessKey: accessTokenResponse.secret,
	},
	region: environment.ContentBucketRegion,
});
await createRequest(
	s3Client, // TS2345: Argument of type S3 is not assignable to parameter of type Client<any, ServiceInputTypes, MetadataBearer, any> Types have separate declarations of a private property handler
	new GetObjectCommand({
		Bucket: environment.ContentBucketName,
		Key: FileStorageService.getS3ObjectKey(payload),
	}),
)

Observed Behavior

tsc generates:

 error TS2345: Argument of type 'S3' is not assignable to parameter of type 'Client<any, ServiceInputTypes, MetadataBearer, any>'.
  Types have separate declarations of a private property 'handlers'.
node_modules/@aws-sdk/s3-request-presigner/node_modules/@smithy/core/protocols.d.ts(6,3): error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'RequestBuilder'. Consider explicitly re-exporting to resolve the ambiguity.
node_modules/@aws-sdk/s3-request-presigner/node_modules/@smithy/core/protocols.d.ts(6,3): error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'collectBody'. Consider explicitly re-exporting to resolve the ambiguity.
node_modules/@aws-sdk/s3-request-presigner/node_modules/@smithy/core/protocols.d.ts(6,3): error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'extendedEncodeURIComponent'. Consider explicitly re-exporting to resolve the ambiguity.
node_modules/@aws-sdk/s3-request-presigner/node_modules/@smithy/core/protocols.d.ts(6,3): error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'requestBuilder'. Consider explicitly re-exporting to resolve the ambiguity.
node_modules/@aws-sdk/s3-request-presigner/node_modules/@smithy/core/protocols.d.ts(6,3): error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'resolvedPath'. Consider explicitly re-exporting to resolve the ambiguity.

Expected Behavior

Minor version update would not introduce incompatible types.

Possible Solution

No response

Additional Information/Context

No response

@KeithGillette KeithGillette added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 12, 2025
@github-actions github-actions bot added the potential-regression Marking this issue as a potential regression to be checked by team member label Jan 12, 2025
@aBurmeseDev aBurmeseDev self-assigned this Jan 15, 2025
@aBurmeseDev
Copy link
Member

Hi @KeithGillette - thanks for reaching out.

I'm not able to reproduce this error on my end. This type of error is most likely due to packages/dependencies installed being on different versions. Could you double check to verify that @aws-sdk/xxxx dependencies in the package.json is the same version? Feel free to share your package.json if issue persists.

@aBurmeseDev aBurmeseDev added response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Jan 15, 2025
@KeithGillette
Copy link
Author

Thanks for testing, @aBurmeseDev. There is no 3.726.1 release of @aws-sdk/util-create-request, among other @aws-sdk/* packages, so no way for them all to be at the same version. Here are the relevant portions of package.json from the project where I am experiencing the reported errors:

 "dependencies": {
    "@accounts/apollo-link": "0.32.1",
    "@accounts/client": "0.33.1",
    "@accounts/graphql-api": "0.33.2",
    "@accounts/graphql-client": "0.33.1",
    "@accounts/magic-link": "0.1.1",
    "@accounts/mongo": "0.34.1",
    "@accounts/mongo-password": "0.33.0",
    "@accounts/password": "0.32.2",
    "@accounts/server": "0.33.1",
    "@angular/animations": "19.0.6",
    "@angular/cdk": "19.0.5",
    "@angular/common": "19.0.6",
    "@angular/compiler": "19.0.6",
    "@angular/core": "19.0.6",
    "@angular/forms": "19.0.6",
    "@angular/platform-browser": "19.0.6",
    "@angular/platform-browser-dynamic": "19.0.6",
    "@angular/router": "19.0.6",
    "@angular/service-worker": "19.0.6",
    "@apollo/client": "3.12.5",
    "@apollo/server": "4.11.3",
    "@aws-crypto/sha256-browser": "5.2.0",
    "@aws-sdk/client-bedrock-runtime": "3.726.1",
    "@aws-sdk/client-s3": "3.726.1",
    "@aws-sdk/s3-request-presigner": "3.726.1",
    "@aws-sdk/util-create-request": "3.723.0",
    "@aws-sdk/util-format-url": "3.723.0",
    "@bugsplat/angular-tree-component": "18.0.0",
    "@danielmoncada/angular-datetime-picker": "19.0.0",
    "@graphql-modules/core": "0.7.17",
    "@graphql-tools/graphql-file-loader": "8.0.11",
    "@graphql-tools/load": "8.0.12",
    "@graphql-tools/schema": "10.0.16",
    "@graphql-tools/utils": "10.7.2",
    "@hokify/agenda": "6.3.0",
    "@ng-web-apis/common": "4.11.1",
    "@ngneat/helipopper": "9.2.1",
    "@ngneat/until-destroy": "10.0.0",
    "@node-oauth/oauth2-server": "5.2.0",
    "@nx/angular": "20.3.1",
    "@stripe/stripe-js": "5.5.0",
    "@typegoose/typegoose": "12.10.1",
    "angular-shepherd": "18.0.2",
    "angular-split": "18.0.0",
    "apollo-angular": "8.0.0",
    "axios": "1.7.9",
    "backoff-rxjs": "7.0.0",
    "body-parser": "1.20.3",
    "bootstrap": "5.3.3",
    "bson-objectid": "2.0.4",
    "chart.js": "4.4.7",
    "class-validator": "0.14.1",
    "core-js": "3.40.0",
    "cors": "2.8.5",
    "date-fns": "4.1.0",
    "express": "4.21.2",
    "file-saver": "2.0.5",
    "font-awesome": "4.7.0",
    "graphql": "16.10.0",
    "graphql-subscriptions": "3.0.0",
    "graphql-ws": "5.16.2",
    "highlight.js": "11.11.1",
    "injection-js": "2.4.0",
    "jszip": "3.10.1",
    "lodash": "4.17.21",
    "lodash-es": "4.17.21",
    "lodash-unified": "1.0.3",
    "metascraper": "5.46.1",
    "metascraper-audio": "5.46.1",
    "metascraper-author": "5.46.1",
    "metascraper-description": "5.46.1",
    "metascraper-image": "5.46.1",
    "metascraper-title": "5.46.1",
    "metascraper-video": "5.46.1",
    "mobile-drag-drop": "3.0.0-rc.0",
    "mongodb": "6.12.0",
    "mongoose": "8.9.4",
    "ngx-avatars": "1.8.0",
    "ngx-google-analytics": "14.0.1",
    "ngx-print": "2.0.0",
    "ngx-quill": "27.0.0",
    "ngx-stripe": "19.0.0",
    "nodemailer": "6.9.16",
    "primeicons": "7.0.0",
    "primeng": "17.18.15",
    "quill": "2.0.2",
    "quill-emoji": "git+https://github.com/artknight/quill-emoji.git",
    "quill-mention": "6.0.2",
    "rxjs": "7.8.1",
    "stripe": "17.5.0",
    "tslib": "2.8.1",
    "winston": "3.17.0",
    "winston-mongodb": "6.0.0",
    "ws": "8.18.0",
    "zapier-platform-core": "16.1.0",
    "zone.js": "0.15.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "19.0.7",
    "@angular-devkit/core": "19.0.7",
    "@angular-devkit/schematics": "19.0.7",
    "@angular-eslint/builder": "19.0.2",
    "@angular-eslint/eslint-plugin": "19.0.2",
    "@angular-eslint/eslint-plugin-template": "19.0.2",
    "@angular-eslint/schematics": "19.0.2",
    "@angular-eslint/template-parser": "19.0.2",
    "@angular/cli": "19.0.7",
    "@angular/compiler-cli": "19.0.6",
    "@angular/language-service": "19.0.6",
    "@graphql-eslint/eslint-plugin": "4.3.0",
    "@nx/eslint": "20.3.1",
    "@nx/jest": "20.3.1",
    "@nx/node": "20.3.1",
    "@nx/workspace": "20.3.1",
    "@schematics/angular": "19.0.7",
    "@stylistic/eslint-plugin": "2.13.0",
    "@types/chart.js": "2.9.41",
    "@types/cors": "2.8.17",
    "@types/file-saver": "2.0.7",
    "@types/jest": "29.5.14",
    "@types/lodash-es": "4.17.12",
    "@types/mime-types": "2.1.4",
    "@types/node": "20.17.12",
    "@types/nodemailer": "6.4.17",
    "@types/request-promise": "4.1.51",
    "@types/ws": "8.5.13",
    "@types/yargs": "17.0.33",
    "@typescript-eslint/eslint-plugin": "8.19.1",
    "@typescript-eslint/parser": "8.19.1",
    "@typescript-eslint/utils": "8.19.1",
    "concurrently": "9.1.2",
    "dotenv": "16.4.7",
    "eslint": "8.57.1",
    "eslint-plugin-import": "2.31.0",
    "eslint-plugin-jsdoc": "50.6.1",
    "eslint-plugin-prefer-arrow": "1.2.3",
    "eslint-plugin-rxjs": "5.0.3",
    "eslint-plugin-unicorn": "56.0.1",
    "jest": "29.7.0",
    "jest-environment-jsdom": "29.7.0",
    "jest-preset-angular": "14.5.0",
    "localtunnel": "2.0.2",
    "nx": "20.3.1",
    "rimraf": "6.0.1",
    "stylelint": "16.13.0",
    "stylelint-config-standard-scss": "14.0.0",
    "ts-jest": "29.2.5",
    "ts-node": "10.9.2",
    "typescript": "5.6.3",
    "xmlhttprequest": "1.8.0",
    "yargs": "17.7.2",
    "zapier-platform-cli": "16.1.0"
  }

@stemail23
Copy link

I have similar issues after upgrading @aws-sdk/client-s3 and @aws-sdk/s3-request-presigner from 3.723.0 to 3.726.1.

await s3GetSignedUrl(new S3Client(), … results in compile time error:

Argument of type 'S3Client' is not assignable to parameter of type 'Client<any, ServiceInputTypes, MetadataBearer, any>'.
  The types of 'middlewareStack.add' are incompatible between these types. […]

@Sheldenshi
Copy link

I have the same issue and downgrading to 3.723.0 didn't help

@SageGary
Copy link

I am also seeing the same TS2308 errors when Dependabot updated @aws-sdk/client-docdb from 3.699.0 to 3.726.1 in package-lock.json

node_modules/@aws-sdk/client-docdb/node_modules/@smithy/core/protocols.d.ts(6,3): error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'RequestBuilder'. Consider explicitly re-exporting to resolve the ambiguity.
node_modules/@aws-sdk/client-docdb/node_modules/@smithy/core/protocols.d.ts(6,3): error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'collectBody'. Consider explicitly re-exporting to resolve the ambiguity.
node_modules/@aws-sdk/client-docdb/node_modules/@smithy/core/protocols.d.ts(6,3): error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'extendedEncodeURIComponent'. Consider explicitly re-exporting to resolve the ambiguity.
node_modules/@aws-sdk/client-docdb/node_modules/@smithy/core/protocols.d.ts(6,3): error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'requestBuilder'. Consider explicitly re-exporting to resolve the ambiguity.
node_modules/@aws-sdk/client-docdb/node_modules/@smithy/core/protocols.d.ts(6,3): error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'resolvedPath'. Consider explicitly re-exporting to resolve the ambiguity.

@aBurmeseDev
Copy link
Member

@KeithGillette - thanks for sharing your package.json.

The root cause here is due to node_modules nesting and duplication when handling transitive dependencies that exist at multiple different versions within a single workspace. Most commonly, this is caused by an application installing different versions of various SDK clients that all depend on @smithy/types or @aws-sdk/types.

To resolve this, you can either install @aws-sdk/xxx with <= version prefix like "<=3.726.1" or do the following:

  • Delete your package-lock.json
  • Delete your node_modules folder
  • Run npm install

cc: @stemail23 @Sheldenshi @SageGary

Hope it helps,
John

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. label Jan 16, 2025
@KeithGillette
Copy link
Author

Right you are, @aBurmeseDev. I verified that deleting package-lock.json & node_modules resolves the mismatched typings (with the now released 3.729.0 S3 packages). Thanks for taking time to provide the guidance!

Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p2 This is a standard priority issue potential-regression Marking this issue as a potential regression to be checked by team member
Projects
None yet
Development

No branches or pull requests

5 participants