Skip to content

SQS returns 404 for change-message-visibility and delete-message

0

As per documents, ReceiptHandleIsInvalid error code is 400.

In case if receipt handle is invalid (case 1) or receipt handle is valid but queue is different (case 2), changeMessageVisibility and deleteMessage returns 404 ReceiptHandleIsInvalid error.

Is this expected for both the use case ?

2 Answers
1

I tested both scenarios for both deleteMessage and changeMessageVisibility operations and I confirm both return 404 error codes which contradicts the documentation.

I would recommend to report this behavior to AWS Support and ask for clarification, as it represents an inconsistency between expected HTTP status code and the actual implementation.

2025-08-04 10:41:33,120 - MainThread - urllib3.connectionpool - DEBUG - https://sqs.eu-west-1.amazonaws.com:443 "POST / HTTP/1.1" 404 530
AWS

answered a year ago

1

Thank you for raising this question about Amazon SQS error codes.

You've identified an important discrepancy between documentation and actual service behavior. After investigating this issue with our AWS SQS specialists, I can confirm your observation is accurate.

While the AWS documentation for the DeleteMessage[1] and ChangeMessageVisibility[2] APIs specifies that ReceiptHandleIsInvalid errors should return a 400 status code, the service currently returns a 404 Not Found HTTP code in both scenarios:

  1. When the receipt handle is completely invalid
  2. When the receipt handle is valid but used with a different queue

According to our internal experts, this behavior exists because:

  • Traditionally, 400 Bad Request is used for invalid parameters (as documented)
  • However, 404 Not Found is used when the system cannot locate the referenced resource

In Amazon SQS specifically, both status codes can be returned for ReceiptHandleIsInvalid errors depending on the exact circumstances.

To ensure robust application behavior, we recommend implementing error handling that accounts for both 400 and 404 status codes when dealing with ReceiptHandleIsInvalid errors.

I've submitted a request to update our official documentation to accurately reflect both possible status codes. This should help prevent confusion for other customers in the future.

Thank you for bringing this to our attention.

=====

References:

[1] DeleteMessage API - https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_DeleteMessage.html

[2] ChangeMessageVisibility API - https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ChangeMessageVisibility.html

answered a year ago

AWS
SUPPORT ENGINEER

revised a year ago

AWS
SUPPORT ENGINEER

revised a year ago

AWS
SUPPORT ENGINEER

revised a year ago

AWS
SUPPORT ENGINEER

revised a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.