With botocore 1.34.17, attempting to load or get a non-existent SQS queue would raise a sqs.meta.client.exceptions.QueueDoesNotExist exception. With newer versions of the boto package, this exception is no longer raised when using moto and the more general ClientError exception is raised instead.
Versions:
moto v5.0.10
boto3 v1.34.138
botocore v1.34.138
Python v3.12.3
Working versions:
boto3 v1.34.17
botocore v.1.34.17
I am using moto mocks
It appears that newer versions of boto do not contain fully qualified names like "AWS.SimpleQueueService.NonExistentQueue" in it's exception map. In newer versions of boto, the QueryErrorCode property is set to "QueueDoesNotExist" when calling real AWS while the ErrorCode is still "AWS.SimpleQueueService.NonExistentQueue". The QueryErrorCode takes precedence over ErrorCode when mapping exceptions per this code in botocore.client, and moto is not setting QueryErrorCode, only ErrorCode
# botocore.client line 1015
if http.status_code >= 300:
error_info = parsed_response.get("Error", {})
error_code = error_info.get("QueryErrorCode") or error_info.get(
"Code"
)
error_class = self.exceptions.from_code(error_code)
raise error_class(parsed_response, operation_name)
else:
return parsed_response
Steps to reproduce
from moto import mock_aws
import pytest
@mock_aws
def test_queue_not_exists_exception():
from boto3 import resource
sqs = resource("sqs")
with pytest.raises(sqs.meta.client.exceptions.QueueDoesNotExist):
sqs.get_queue_by_name(QueueName="doesnotexist")
With botocore 1.34.17, attempting to load or get a non-existent SQS queue would raise a sqs.meta.client.exceptions.QueueDoesNotExist exception. With newer versions of the boto package, this exception is no longer raised when using moto and the more general ClientError exception is raised instead.
Versions:
Working versions:
I am using moto mocks
It appears that newer versions of boto do not contain fully qualified names like "AWS.SimpleQueueService.NonExistentQueue" in it's exception map. In newer versions of boto, the QueryErrorCode property is set to "QueueDoesNotExist" when calling real AWS while the ErrorCode is still "AWS.SimpleQueueService.NonExistentQueue". The QueryErrorCode takes precedence over ErrorCode when mapping exceptions per this code in botocore.client, and moto is not setting QueryErrorCode, only ErrorCode
Steps to reproduce