Skip to content

[sqs] Messages should not allow empty bodies #435

Closed
@elazar

Description

@elazar

From the SQS documentation:

The Name, Type, Value, and the message body must not be empty or null.

Passing an empty string as the message body to the AWS SDK results in an exception being thrown that resembles the following.

class: Aws\Sqs\Exception\SqsException

code: 0

file: vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php:192

message: Error executing "SendMessage" on
"https://sqs.us-east-1.amazonaws.com/1234567890/queue-name";
AWS HTTP error: Client error:
`POST https://sqs.us-east-1.amazonaws.com/1234567890/queue-name`
resulted in a `400 Bad Request` response:

MissingParameter (client): The request must contain the parameter MessageBody. - 
<?xml version="1.0"?>
<ErrorResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/">
  <Error>
    <Type>Sender</Type>
    <Code>MissingParameter</Code>
    <Message>The request must contain the parameter MessageBody.</Message>
    <Detail/>
  </Error>
  <RequestId>0cdc8fab-dde9-5c5d-a7fd-dccfd24acec4</RequestId>
</ErrorResponse>

There are a few areas in which the Enqueue SQS transport implementation seems to overlook this requirement.

  • SqsProducer->send() does not check if the body is empty, only that it is a scalar or strictly equal to null. source
  • SqsMessage->__construct() assigns a default value of the empty string to its $body parameter. source
  • SqsMessage->setBody() implements no type or value checks against its $body parameter. source
  • SqsContext->createMessage() assigns a default value of the empty string to its $body parameter. source

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions