Skip to content

[SQS] Messages entry could be missing in ReceiveMessageResult #361

@taesungh

Description

@taesungh

The ReceiveMessageResultTypeDef specifies the "Messages" key as required, but the Boto3 SQS client does not provide a value for that when no messages are received.

If no messages are available and the wait time expires, the call does not return a message list (WaitTimeSeconds parameter for ReceiveMessages)

Side note: the documentation was previously corrected after a discussion in boto/boto3#2518 about this.

Runtime example

Attempt to receive messages from a queue which has no messages available

sqs_client = boto3.client("sqs")
response = sqs_client.receive_message(QueueUrl="...")
response.keys()

The response contains only "ResponseMetadata", no entry for "Messages"

{
    "ResponseMetadata": {
        "RequestId": "...",
        "HTTPStatusCode": 200,
        ...
    }
}

Current stub

class ReceiveMessageResultTypeDef(TypedDict):
    Messages: list[MessageTypeDef]
    ResponseMetadata: ResponseMetadataTypeDef

Expected stub

class ReceiveMessageResultTypeDef(TypedDict):
    Messages: NotRequired[list[MessageTypeDef]]
    ResponseMetadata: ResponseMetadataTypeDef

Additional context

Ran using Boto3 version 1.38.45 on Python 3.13.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞 bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions