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.ReceiveMessageRequest.AttributeNames does not allow MessageSystemAttributeName #5403

Closed
3 tasks done
baumac opened this issue Oct 23, 2023 · 11 comments
Closed
3 tasks done
Assignees
Labels
bug This issue is a bug. p1 This is a high priority issue service-api This issue is due to a problem in a service API, not the SDK implementation.

Comments

@baumac
Copy link

baumac commented Oct 23, 2023

Checkboxes for prior research

Describe the bug

The ReceiveMessageRequest.AttributeNames only allows values from the AttributeNames enum, and does not allow values from the MessageSystemAttributeName enum. This contradicts the docs which list MessageSystemAttributeName as valid values for the AttributeNames field.

AttributeNames are defined as:

  A list of attributes that need to be returned along with each message. These attributes include:
  All – Returns all values.
  ApproximateFirstReceiveTimestamp – Returns the time the message was first received from the queue (epoch time  in milliseconds).
  ApproximateReceiveCount – Returns the number of times a message has been received across all queues but not deleted.
  AWSTraceHeader – Returns the X-Ray trace header string.
  SenderId
  For a user, returns the user ID, for example ABCDEFGHI1JKLMNOPQ23R.
  For an IAM role, returns the IAM role ID, for example ABCDE1F2GH3I4JK5LMNOP:i-a123b456.
  SentTimestamp – Returns the time the message was sent to the queue (epoch time  in milliseconds).
  SqsManagedSseEnabled – Enables server-side queue encryption using SQS owned encryption keys. Only one server-side encryption option is supported per queue (for example, SSE-KMS  or SSE-SQS ).
  MessageDeduplicationId – Returns the value provided by the producer that calls the SendMessage action.
  MessageGroupId – Returns the value provided by the producer that calls the SendMessage action. Messages with the same MessageGroupId are returned in sequence.
  SequenceNumber – Returns the value provided by Amazon SQS.

SDK version number

@aws-sdk/client-sqs@3.428.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v18.18.1

Reproduction Steps

Example code that worked in v3.427.0:

const sqsClient = new SQSClient();
const receiveMessageCommand = new ReceiveMessageCommand({
  MessageAttributeNames: ['All'],
  AttributeNames: ['SentTimestamp', 'ApproximateReceiveCount']
})

This works because AttributeNames is defined as:

AttributeNames?: (QueueAttributeName | string)[];

Observed Behavior

In v3.428.0 the code gives the following error because of the type definition to AttributeNames:

ReceiveMessageRequest.AttributeNames?: QueueAttributeName[] | undefined

Expected Behavior

The provided example should work in both v3.427.0 and v3.428.0.

Possible Solution

The quick fix is to update AttributeNames to accept an Array of both MessageSystemAttributeName and QueueAttributeName i.e define it as AttributeNames?: (QueueAttributeName | MessageSystemAttributeName)[];

The longer fix might requiring updating every place that uses Attribute names to allow using MessageSystemAttributeName, QueueAttributeName, or both.

Additional Information/Context

No response

@baumac baumac added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 23, 2023
@baumac
Copy link
Author

baumac commented Oct 23, 2023

@kuhe tagging you as this closely relates to #5387

@yenfryherrerafeliz
Copy link
Contributor

Related: aws/aws-sdk#623

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

kuhe commented Oct 23, 2023

We want the service to update their model (@yenfryherrerafeliz has an internal ticket open and will relay updates), which generates the types here. Please use a typecast as a workaround until then.

We will not likely go back to using open enums, since it is too loose for most models, even though it unfortunately breaks this use case.

@trivikr trivikr added the service-api This issue is due to a problem in a service API, not the SDK implementation. label Nov 7, 2023
@aBurmeseDev
Copy link
Member

Hello @baumac - I just wanted to follow up here with an update that we're still waiting on a fix from service team and it's currently being worked on (ref: V1073281478). In the meantime, please refer to the workaround mentioned above. Feel free to check back in for updates in the near future.

Thanks,
John

@dormesica
Copy link

@aBurmeseDev Is there an estimation on when this issue is going to be fixed? It prevents us from upgrading above version 3.428.0

@aBurmeseDev
Copy link
Member

Hi @dormesica - thanks for checking in.
Upon checking, I don't see any new updates from the service team but I reached out asking if there's any update they can provide. Meanwhile, please use a typecast as workaround mentioned above. I'll check back in when I hear back.

@renarsvilnis
Copy link

@aBurmeseDev any updates one this?

@aBurmeseDev
Copy link
Member

Hi everyone - thank you all for your patience. I wanted to share an update that the fix has now been released by service team as of last week and I was able to confirm it with latest version of SDK.

cc: @baumac @renarsvilnis @dormesica

@renarsvilnis
Copy link

renarsvilnis commented May 14, 2024

@aBurmeseDev is it there as of 3.576.0 version (seeing still the issue) or it's going to the next release?

Our code
Screenshot 2024-05-14 at 22 52 38

Library types
Screenshot 2024-05-14 at 22 51 39

@baumac
Copy link
Author

baumac commented May 21, 2024

@renarsvilnis per the JSDoc comment, the AttributeNames property has been deprecated and you should use the MessageSystemAttributeNames property which is of type MessageSystemAttributeName[]. The MessageSystemAttributeName enum should contain all the attributes you are looking for.

export declare const MessageSystemAttributeName: {
    readonly AWSTraceHeader: "AWSTraceHeader";
    readonly All: "All";
    readonly ApproximateFirstReceiveTimestamp: "ApproximateFirstReceiveTimestamp";
    readonly ApproximateReceiveCount: "ApproximateReceiveCount";
    readonly DeadLetterQueueSourceArn: "DeadLetterQueueSourceArn";
    readonly MessageDeduplicationId: "MessageDeduplicationId";
    readonly MessageGroupId: "MessageGroupId";
    readonly SenderId: "SenderId";
    readonly SentTimestamp: "SentTimestamp";
    readonly SequenceNumber: "SequenceNumber";
};

Copy link

github-actions bot commented Jun 6, 2024

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 Jun 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. p1 This is a high priority issue service-api This issue is due to a problem in a service API, not the SDK implementation.
Projects
None yet
Development

No branches or pull requests

7 participants