In Typescript, SQS.ReceiveMessageRequest.AttributeNames does not allow MessageSystemAttributeName
Checkboxes for prior research
- [X] I've gone through Developer Guide and API reference
- [X] I've checked AWS Forums and StackOverflow.
- [X] I've searched for previous similar issues and didn't find any solution.
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/[email protected]
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
@kuhe tagging you as this closely relates to https://github.com/aws/aws-sdk-js-v3/issues/5387
Related: https://github.com/aws/aws-sdk/issues/623
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.
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
@aBurmeseDev Is there an estimation on when this issue is going to be fixed? It prevents us from upgrading above version 3.428.0
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.
@aBurmeseDev any updates one this?
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
@aBurmeseDev is it there as of 3.576.0 version (seeing still the issue) or it's going to the next release?
Our code
Library types
@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";
};
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.