m-radzikowski / aws-sdk-client-mock

AWS JavaScript SDK v3 mocks for easy unit testing. 🖋️ Typed 🔬 Tested 📄 Documented 🛠️ Maintained
https://m-radzikowski.github.io/aws-sdk-client-mock/
MIT License
788 stars 39 forks source link

Not able to setup S3 mock for GetObjectCommand #234

Open bpadhiyar4 opened 1 month ago

bpadhiyar4 commented 1 month ago

Checklist

Bug description

I am trying to mock S3 Getobject method and I followed the same as mentioned in the readme file but it seems it is not working. I check @smithy/type version as well all of the packages are pointing to same version. Below. I am attaching error I am getting and @smity/type logs.

Type SdkStream<ReadableStream | Blob> | SdkStream<Readable> is not assignable to type StreamingBlobPayloadOutputTypes | undefined Type ReadableStream & SdkStreamMixin is not assignable to type StreamingBlobPayloadOutputTypes | undefined Type ReadableStream & SdkStreamMixin is not assignable to type IncomingMessage & SdkStreamMixin Type ReadableStream & SdkStreamMixin is missing the following properties from type IncomingMessage: aborted, httpVersion, httpVersionMajor, httpVersionMinor

@smithy/types logs:

├─┬ @aws-sdk/client-lambda@3.609.0 │ ├─┬ @aws-sdk/client-sso-oidc@3.609.0 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @aws-sdk/client-sts@3.609.0 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @aws-sdk/core@3.609.0 │ │ ├─┬ @smithy/signature-v4@3.1.2 │ │ │ └── @smithy/types@3.3.0 deduped │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @aws-sdk/credential-provider-node@3.609.0 │ │ ├─┬ @aws-sdk/credential-provider-env@3.609.0 │ │ │ └── @smithy/types@3.3.0 deduped │ │ ├─┬ @aws-sdk/credential-provider-http@3.609.0 │ │ │ └── @smithy/types@3.3.0 deduped │ │ ├─┬ @aws-sdk/credential-provider-ini@3.609.0 │ │ │ └── @smithy/types@3.3.0 deduped │ │ ├─┬ @aws-sdk/credential-provider-process@3.609.0 │ │ │ └── @smithy/types@3.3.0 deduped │ │ ├─┬ @aws-sdk/credential-provider-sso@3.609.0 │ │ │ ├─┬ @aws-sdk/client-sso@3.609.0 │ │ │ │ └── @smithy/types@3.3.0 deduped │ │ │ ├─┬ @aws-sdk/token-providers@3.609.0 │ │ │ │ └── @smithy/types@3.3.0 deduped │ │ │ └── @smithy/types@3.3.0 deduped │ │ ├─┬ @aws-sdk/credential-provider-web-identity@3.609.0 │ │ │ └── @smithy/types@3.3.0 deduped │ │ ├─┬ @smithy/credential-provider-imds@3.1.3 │ │ │ └── @smithy/types@3.3.0 deduped │ │ ├─┬ @smithy/property-provider@3.1.3 │ │ │ └── @smithy/types@3.3.0 deduped │ │ ├─┬ @smithy/shared-ini-file-loader@3.1.3 │ │ │ └── @smithy/types@3.3.0 deduped │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @aws-sdk/middleware-host-header@3.609.0 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @aws-sdk/middleware-logger@3.609.0 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @aws-sdk/middleware-recursion-detection@3.609.0 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @aws-sdk/middleware-user-agent@3.609.0 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @aws-sdk/region-config-resolver@3.609.0 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @aws-sdk/types@3.609.0 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @aws-sdk/util-endpoints@3.609.0 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @aws-sdk/util-user-agent-browser@3.609.0 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @aws-sdk/util-user-agent-node@3.609.0 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/config-resolver@3.0.4 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/core@2.2.4 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/eventstream-serde-browser@3.0.4 │ │ ├─┬ @smithy/eventstream-serde-universal@3.0.4 │ │ │ ├─┬ @smithy/eventstream-codec@3.1.2 │ │ │ │ └── @smithy/types@3.3.0 deduped │ │ │ └── @smithy/types@3.3.0 deduped │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/eventstream-serde-config-resolver@3.0.3 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/eventstream-serde-node@3.0.4 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/fetch-http-handler@3.2.0 │ │ ├─┬ @smithy/querystring-builder@3.0.3 │ │ │ └── @smithy/types@3.3.0 deduped │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/hash-node@3.0.3 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/invalid-dependency@3.0.3 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/middleware-content-length@3.0.3 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/middleware-endpoint@3.0.4 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/middleware-retry@3.0.7 │ │ ├─┬ @smithy/service-error-classification@3.0.3 │ │ │ └── @smithy/types@3.3.0 deduped │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/middleware-serde@3.0.3 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/middleware-stack@3.0.3 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/node-config-provider@3.1.3 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/node-http-handler@3.1.1 │ │ ├─┬ @smithy/abort-controller@3.1.1 │ │ │ └── @smithy/types@3.3.0 deduped │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/protocol-http@4.0.3 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/smithy-client@3.1.5 │ │ └── @smithy/types@3.3.0 deduped │ ├── @smithy/types@3.3.0 │ ├─┬ @smithy/url-parser@3.0.3 │ │ ├─┬ @smithy/querystring-parser@3.0.3 │ │ │ └── @smithy/types@3.3.0 deduped │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/util-defaults-mode-browser@3.0.7 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/util-defaults-mode-node@3.0.7 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/util-endpoints@2.0.4 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/util-middleware@3.0.3 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/util-retry@3.0.3 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/util-stream@3.0.5 │ │ └── @smithy/types@3.3.0 deduped │ └─┬ @smithy/util-waiter@3.1.2 │ └── @smithy/types@3.3.0 deduped ├─┬ @aws-sdk/client-rds-data@3.609.0 │ └── @smithy/types@3.3.0 deduped ├─┬ @aws-sdk/client-s3@3.609.0 │ ├─┬ @aws-sdk/middleware-bucket-endpoint@3.609.0 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @aws-sdk/middleware-expect-continue@3.609.0 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @aws-sdk/middleware-flexible-checksums@3.609.0 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @aws-sdk/middleware-location-constraint@3.609.0 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @aws-sdk/middleware-sdk-s3@3.609.0 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @aws-sdk/middleware-signing@3.609.0 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @aws-sdk/middleware-ssec@3.609.0 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @aws-sdk/signature-v4-multi-region@3.609.0 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @aws-sdk/xml-builder@3.609.0 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/hash-blob-browser@3.1.2 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/hash-stream-node@3.1.2 │ │ └── @smithy/types@3.3.0 deduped │ ├─┬ @smithy/md5-js@3.0.3 │ │ └── @smithy/types@3.3.0 deduped │ └── @smithy/types@3.3.0 deduped ├─┬ @aws-sdk/s3-request-presigner@3.609.0 │ ├─┬ @aws-sdk/util-format-url@3.609.0 │ │ └── @smithy/types@3.3.0 deduped │ └── @smithy/types@3.3.0 deduped └─┬ @aws-sdk/util-stream-node@3.374.0 └─┬ @smithy/util-stream-node@1.1.0 ├─┬ @smithy/node-http-handler@1.1.0 │ ├─┬ @smithy/abort-controller@1.1.0 │ │ └── @smithy/types@1.2.0 deduped │ ├─┬ @smithy/protocol-http@1.2.0 │ │ └── @smithy/types@1.2.0 deduped │ ├─┬ @smithy/querystring-builder@1.1.0 │ │ └── @smithy/types@1.2.0 deduped │ └── @smithy/types@1.2.0 deduped └── @smithy/types@1.2.0

Reproduction

Code is same as provided in Readme file for GetObjectCommand

Environment

mousedownmike commented 1 month ago

Similar results with NodeJS 20 with TypeScript 5.5.4

Ayushi1612 commented 1 month ago

Facing similar issue

drwoods commented 1 month ago

Seems related to SDK changes as if I use 3.523.0 it works but upgrading to newest version 3.624.0 fails with the above mentioned issue.

RichardBradley commented 1 month ago

I have seen the same problem, using the latest versions of aws-sdk-client-mock (4.0.1), aws-sdk (3.624.0) and @smithy/util-stream (3.1.3)

I have been able to work around by adding as any to the Body arg, so it appears to just be a typings issue.

jci-aws commented 4 weeks ago

I'm seeing the issue with @aws-sdk/client-glue between versions 3.574.0 (no typing issues) and 3.575.0 (typing issues).

The common change in multiple clients between 3.574.0 and 3.575.0 is this commit which upgrades the smithy dependency version from 1.* to 2.0 in a bunch of clients.