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

In Typescript, SQS.CreateQueueCommand requires all queue attributes due to Attributes having type Record<QueueAttributeName, string> #5387

Closed
3 tasks done
suchanpark-koioi opened this issue Oct 19, 2023 · 5 comments
Assignees
Labels
bug This issue is a bug. closing-soon This issue will automatically close in 4 days unless further comments are made. p1 This is a high priority issue pending-release This issue will be fixed by an approved PR that hasn't been released yet. workaround-available This issue has a work around available.

Comments

@suchanpark-koioi
Copy link

Checkboxes for prior research

Describe the bug

A simple code below:

const sqsClient = new SQSClient();
const createCommandOutput = await sqsClient.send(
  new CreateQueueCommand({
    QueueName: queueName,
    Attributes: {
      RedrivePolicy: JSON.stringify({
        maxReceiveCount: '5',
      }),
    },
  }),
);

gives TypeScript error as follows:

TS2740: Type  { RedrivePolicy: string; }  is missing the following properties from type  Record<QueueAttributeName, string> :
All, ApproximateNumberOfMessages, ApproximateNumberOfMessagesDelayed, ApproximateNumberOfMessagesNotVisible
, and  17  more.

SDK version number

@aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

18.15.0

Reproduction Steps

import {
  CreateQueueCommand,
  SQSClient,
} from '@aws-sdk/client-sqs';

const sqsClient = new SQSClient();
const createCommandOutput = await sqsClient.send(
  new CreateQueueCommand({
    QueueName: 'anyname',
    Attributes: {
      RedrivePolicy: JSON.stringify({
        maxReceiveCount: '5',
      }),
    },
  }),
);

Create a typescript file with the content above and run tsc. Use @aws-sdk/client-sqs with version >=3.430.0.

Observed Behavior

Typescript error that says as below:

TS2740: Type  { RedrivePolicy: string; }  is missing the following properties from type  Record<QueueAttributeName, string> :
All, ApproximateNumberOfMessages, ApproximateNumberOfMessagesDelayed, ApproximateNumberOfMessagesNotVisible
, and  17  more.

Expected Behavior

This code should compile with Typescript.

Specifiying all the parameters is not required, it can be seen as, for example, here: https://docs.aws.amazon.com/cli/latest/reference/sqs/create-queue.html

This code didn't produce Typescript Error at least until 3.421.0.

Possible Solution

Maybe change the type of Attributes into something like Partial< Record<QueueAttributeName, string> >?

Additional Information/Context

Typescript 5.2.2

@suchanpark-koioi suchanpark-koioi added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 19, 2023
@pfumagalli
Copy link

Introduced in #5356 where L1190 of clients/client-sqs/src/models/models_0.ts went:

-  Attributes?: Record<string, string>;
 + Attributes?: Record<QueueAttributeName, string>;

Pinging @kuhe who was the author...

@coderbyheart
Copy link

Similar problem in

eventConfigurations?: Record<EventType, Configuration>;

introduced via 7d31222

UpdateEventConfigurationsRequest.eventConfigurations now requires all properties to be set.

@kuhe kuhe self-assigned this Oct 19, 2023
@kuhe kuhe added p1 This is a high priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Oct 19, 2023
@kuhe
Copy link
Contributor

kuhe commented Oct 19, 2023

Sorry for the breaking change. We will adopt the suggested fix of using Partial for enum keys, to be included in the next available release day.

As a workaround, please override the typing of the enum keyed object or use the previous SDK version for now.

@kuhe kuhe added pending-release This issue will be fixed by an approved PR that hasn't been released yet. workaround-available This issue has a work around available. closing-soon This issue will automatically close in 4 days unless further comments are made. labels Oct 19, 2023
@kuhe
Copy link
Contributor

kuhe commented Oct 23, 2023

@kuhe kuhe closed this as completed Oct 23, 2023
Copy link

github-actions bot commented Nov 7, 2023

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. closing-soon This issue will automatically close in 4 days unless further comments are made. p1 This is a high priority issue pending-release This issue will be fixed by an approved PR that hasn't been released yet. workaround-available This issue has a work around available.
Projects
None yet
Development

No branches or pull requests

4 participants