Error code returned by ChangeMessageVisibility isn't mentioned in the docs

0

This script:

aws sqs send-message --queue-url "$1" --message-body "body"
RECEIPT_HANDLE=$(aws sqs receive-message --queue-url "$1" --visibility-timeout 300 | jq -r .Messages[0].ReceiptHandle)
aws sqs delete-message --queue-url "$1" --receipt-handle "$RECEIPT_HANDLE"
aws sqs change-message-visibility --queue-url "$1" --receipt-handle "$RECEIPT_HANDLE" --visibility-timeout "10"

results in the following error:

An error occurred (InvalidParameterValue) when calling the ChangeMessageVisibility operation: Value <receipt handle value here> for parameter ReceiptHandle is invalid. Reason: Message does not exist or is not available for visibility timeout change.

The InvalidParameterValue error code isn't mentioned anywhere on this page, however: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ChangeMessageVisibility.html

Why is that?

Here's my AWS CLI version: aws-cli/2.7.4 Python/3.9.11 Darwin/22.3.0 exe/x86_64 prompt/off

1 回答
0

Due to encapsulation in the CLI code I'd expect. The CLI is written in Python and the Python SDK (Boto3) does have a specific exception for the error you're hitting - ReceiptHandleIsInvalid in the API, SQS.Client.exceptions.ReceiptHandleIsInvalid in the SDK. It looks like the CLI code for convenience would trap this exception and re-raise as a more generic InvalidParameterValue exception, with its description reflecting the original specific error.

专家
已回答 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则