localstack-dotnet / localstack-dotnet-client

A lightweight .NET client for LocalStack
MIT License
113 stars 5 forks source link

SQS DeleteQueue fails on LocalStack 2.2 #23

Closed Blind-Striker closed 1 year ago

Blind-Striker commented 1 year ago

Using the LocalStack.NET library, when attempting to delete an SQS queue, the operation fails on LocalStack version 2.2. Notably, this operation succeeds with CLI and previous versions of LocalStack (1.3.1 and 2.0).

Related Issue: https://github.com/localstack/localstack/issues/8924

Expected Behavior

Using the LocalStack.NET library, the SQS queue should be deleted successfully when calling the DeleteQueue function, consistent with the behavior observed on LocalStack versions 1.3.1 and 2.0.

Actual Behavior

Delete operation gives error.

Logs:

2023-08-15T20:28:51.761985583Z 2023-08-15T20:28:51.761  INFO --- [   asgi_gw_0] localstack.request.aws     : AWS sqs.CreateQueue => 200; CreateQueueRequest({'QueueName': 'c85c8994-510d-4f6e-801d-4b7753932583-DLQ.fifo', 'Attributes': {'FifoQueue': 'true'}}, headers={'User-Agent': 'aws-sdk-dotnet-coreclr/3.7.200.18 aws-sdk-dotnet-core/3.7.200.17 .NET_Core/7.0.9 OS/Microsoft_Windows_10.0.22621 ClientAsync', 'amz-sdk-invocation-id': '87581c5c-6d6c-40ae-99bb-d2f979236c08', 'amz-sdk-request': 'attempt=1; max=5', 'x-amz-security-token': 'my-AwsSessionToken', 'Host': 'sqs.eu-central-1.amazonaws.com', 'X-Amz-Date': '20230815T202851Z', 'X-Amz-Content-SHA256': '62743f562eb66199a917d414916c2c9ea1c35200bcaccc4b457e5ad914a1d7ed', 'Authorization': 'AWS4-HMAC-SHA256 Credential=my-AwsAccessKeyId/20230815/eu-central-1/sqs/aws4_request, SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;x-amz-date;x-amz-security-token, Signature=1e97ce548572fc8dc72f91ff36b259d479f86fcd6706d2ee14e1fb266cbf7713', 'Content-Length': '143', 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'x-localstack-tgt-api': 'sqs', 'x-moto-account-id': '000000000000'}); CreateQueueResult({'QueueUrl': 'http://sqs.eu-central-1.amazonaws.com/000000000000/c85c8994-510d-4f6e-801d-4b7753932583-DLQ.fifo'}, headers={'Content-Type': 'text/xml', 'Content-Length': '385', 'Connection': 'close', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'HEAD,GET,PUT,POST,DELETE,OPTIONS,PATCH', 'Access-Control-Allow-Headers': 'authorization,cache-control,content-length,content-md5,content-type,etag,location,x-amz-acl,x-amz-content-sha256,x-amz-date,x-amz-request-id,x-amz-security-token,x-amz-tagging,x-amz-target,x-amz-user-agent,x-amz-version-id,x-amzn-requestid,x-localstack-target,amz-sdk-invocation-id,amz-sdk-request', 'Access-Control-Expose-Headers': 'etag,x-amz-version-id'})
2023-08-15T20:28:51.781754058Z 2023-08-15T20:28:51.781 DEBUG --- [   asgi_gw_0] l.aws.serving.wsgi         : POST sqs.eu-central-1.amazonaws.comhttp://sqs.eu-central-1.amazonaws.com/000000000000/c85c8994-510d-4f6e-801d-4b7753932583-DLQ.fifo
2023-08-15T20:28:51.783127552Z 2023-08-15T20:28:51.783 DEBUG --- [   asgi_gw_0] l.aws.protocol.serializer  : No accept header given. Using request's Content-Type (application/x-www-form-urlencoded; charset=utf-8) as preferred response Content-Type.
2023-08-15T20:28:51.783548737Z 2023-08-15T20:28:51.783  INFO --- [   asgi_gw_0] localstack.request.aws     : AWS sqs.GetQueueAttributes => 200; GetQueueAttributesRequest({'QueueUrl': None, 'AttributeNames': ['QueueArn']}, headers={'User-Agent': 'aws-sdk-dotnet-coreclr/3.7.200.18 aws-sdk-dotnet-core/3.7.200.17 .NET_Core/7.0.9 OS/Microsoft_Windows_10.0.22621 ClientAsync', 'amz-sdk-invocation-id': '012b6c13-4afa-4555-b090-e78392da68ec', 'amz-sdk-request': 'attempt=1; max=5', 'x-amz-security-token': 'my-AwsSessionToken', 'Host': 'sqs.eu-central-1.amazonaws.com', 'X-Amz-Date': '20230815T202851Z', 'X-Amz-Content-SHA256': '6af491181b9d88aef50bfaefb28263f67b71658ce5c3820d3db0f4de1aeed054', 'Authorization': 'AWS4-HMAC-SHA256 Credential=my-AwsAccessKeyId/20230815/eu-central-1/sqs/aws4_request, SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;x-amz-date;x-amz-security-token, Signature=01f05262c5cb1615577f075b22310dfebcbbfff71b5597ebb7116f7189f4db9e', 'Content-Length': '69', 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'x-localstack-tgt-api': 'sqs', 'x-moto-account-id': '000000000000'}); GetQueueAttributesResult({'Attributes': {'QueueArn': 'arn:aws:sqs:eu-central-1:000000000000:c85c8994-510d-4f6e-801d-4b7753932583-DLQ.fifo'}}, headers={'Content-Type': 'text/xml', 'Content-Length': '438', 'Connection': 'close', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'HEAD,GET,PUT,POST,DELETE,OPTIONS,PATCH', 'Access-Control-Allow-Headers': 'authorization,cache-control,content-length,content-md5,content-type,etag,location,x-amz-acl,x-amz-content-sha256,x-amz-date,x-amz-request-id,x-amz-security-token,x-amz-tagging,x-amz-target,x-amz-user-agent,x-amz-version-id,x-amzn-requestid,x-localstack-target,amz-sdk-invocation-id,amz-sdk-request', 'Access-Control-Expose-Headers': 'etag,x-amz-version-id'})
2023-08-15T20:28:51.801249377Z 2023-08-15T20:28:51.801 DEBUG --- [   asgi_gw_0] l.aws.serving.wsgi         : POST sqs.eu-central-1.amazonaws.comhttp://sqs.eu-central-1.amazonaws.com/
2023-08-15T20:28:51.802294585Z 2023-08-15T20:28:51.802 DEBUG --- [   asgi_gw_0] l.services.sqs.provider    : creating queue key=c85c8994-510d-4f6e-801d-4b7753932583.fifo attributes={'FifoQueue': 'true', 'RedrivePolicy': '{"maxReceiveCount":"1","deadLetterTargetArn":"arn:aws:sqs:eu-central-1:000000000000:c85c8994-510d-4f6e-801d-4b7753932583-DLQ.fifo"}'} tags=None
2023-08-15T20:28:51.802379784Z 2023-08-15T20:28:51.802 DEBUG --- [   asgi_gw_0] l.aws.protocol.serializer  : No accept header given. Using request's Content-Type (application/x-www-form-urlencoded; charset=utf-8) as preferred response Content-Type.
2023-08-15T20:28:51.802886258Z 2023-08-15T20:28:51.802  INFO --- [   asgi_gw_0] localstack.request.aws     : AWS sqs.CreateQueue => 200; CreateQueueRequest({'QueueName': 'c85c8994-510d-4f6e-801d-4b7753932583.fifo', 'Attributes': {'FifoQueue': 'true', 'RedrivePolicy': '{"maxReceiveCount":"1","deadLetterTargetArn":"arn:aws:sqs:eu-central-1:000000000000:c85c8994-510d-4f6e-801d-4b7753932583-DLQ.fifo"}'}}, headers={'User-Agent': 'aws-sdk-dotnet-coreclr/3.7.200.18 aws-sdk-dotnet-core/3.7.200.17 .NET_Core/7.0.9 OS/Microsoft_Windows_10.0.22621 ClientAsync', 'amz-sdk-invocation-id': '461c8546-c9aa-4a10-8ddd-db4d158c79e0', 'amz-sdk-request': 'attempt=1; max=5', 'x-amz-security-token': 'my-AwsSessionToken', 'Host': 'sqs.eu-central-1.amazonaws.com', 'X-Amz-Date': '20230815T202851Z', 'X-Amz-Content-SHA256': '1dc9cc6f3965102c46707d37a16b9e67ca44e96240792183727e004b50e33c2c', 'Authorization': 'AWS4-HMAC-SHA256 Credential=my-AwsAccessKeyId/20230815/eu-central-1/sqs/aws4_request, SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;x-amz-date;x-amz-security-token, Signature=c36009b0b3e34498c2b70d3bdc73f3dcf69b047de6b2e751d6154ad632026761', 'Content-Length': '356', 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'x-localstack-tgt-api': 'sqs', 'x-moto-account-id': '000000000000'}); CreateQueueResult({'QueueUrl': 'http://sqs.eu-central-1.amazonaws.com/000000000000/c85c8994-510d-4f6e-801d-4b7753932583.fifo'}, headers={'Content-Type': 'text/xml', 'Content-Length': '381', 'Connection': 'close', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'HEAD,GET,PUT,POST,DELETE,OPTIONS,PATCH', 'Access-Control-Allow-Headers': 'authorization,cache-control,content-length,content-md5,content-type,etag,location,x-amz-acl,x-amz-content-sha256,x-amz-date,x-amz-request-id,x-amz-security-token,x-amz-tagging,x-amz-target,x-amz-user-agent,x-amz-version-id,x-amzn-requestid,x-localstack-target,amz-sdk-invocation-id,amz-sdk-request', 'Access-Control-Expose-Headers': 'etag,x-amz-version-id'})
2023-08-15T20:28:51.808230863Z 2023-08-15T20:28:51.808 DEBUG --- [   asgi_gw_0] l.aws.serving.wsgi         : POST sqs.eu-central-1.amazonaws.comhttp://sqs.eu-central-1.amazonaws.com/000000000000/c85c8994-510d-4f6e-801d-4b7753932583.fifo
2023-08-15T20:28:51.809442889Z 2023-08-15T20:28:51.808 ERROR --- [   asgi_gw_0] l.aws.handlers.logging     : exception during call chain
2023-08-15T20:28:51.809457699Z Traceback (most recent call last):
2023-08-15T20:28:51.809460599Z   File "/opt/code/localstack/localstack/aws/chain.py", line 90, in handle
2023-08-15T20:28:51.809462449Z     handler(self, self.context, response)
2023-08-15T20:28:51.809463979Z   File "/opt/code/localstack/localstack/aws/handlers/service.py", line 123, in __call__
2023-08-15T20:28:51.809465439Z     handler(chain, context, response)
2023-08-15T20:28:51.809466779Z   File "/opt/code/localstack/localstack/aws/handlers/service.py", line 93, in __call__
2023-08-15T20:28:51.809468169Z     skeleton_response = self.skeleton.invoke(context)
2023-08-15T20:28:51.809469499Z   File "/opt/code/localstack/localstack/aws/skeleton.py", line 154, in invoke
2023-08-15T20:28:51.809470869Z     return self.dispatch_request(context, instance)
2023-08-15T20:28:51.809472219Z   File "/opt/code/localstack/localstack/aws/skeleton.py", line 166, in dispatch_request
2023-08-15T20:28:51.809473639Z     result = handler(context, instance) or {}
2023-08-15T20:28:51.809474999Z   File "/opt/code/localstack/localstack/aws/forwarder.py", line 60, in _call
2023-08-15T20:28:51.809483999Z     return handler(context, req)
2023-08-15T20:28:51.809485819Z   File "/opt/code/localstack/localstack/aws/skeleton.py", line 118, in __call__
2023-08-15T20:28:51.809487309Z     return self.fn(*args, **kwargs)
2023-08-15T20:28:51.809488709Z   File "/opt/code/localstack/localstack/services/sqs/provider.py", line 759, in delete_queue
2023-08-15T20:28:51.809494308Z     account_id, region, name = parse_queue_url(queue_url)
2023-08-15T20:28:51.809495798Z   File "/opt/code/localstack/localstack/services/sqs/utils.py", line 32, in parse_queue_url
2023-08-15T20:28:51.809497358Z     url = urlparse(queue_url.rstrip("/"))
2023-08-15T20:28:51.809498768Z AttributeError: 'NoneType' object has no attribute 'rstrip'
2023-08-15T20:28:51.809582387Z 2023-08-15T20:28:51.809 DEBUG --- [   asgi_gw_0] l.aws.protocol.serializer  : No accept header given. Using request's Content-Type (application/x-www-form-urlencoded; charset=utf-8) as preferred response Content-Type.
2023-08-15T20:28:51.810237589Z 2023-08-15T20:28:51.810  INFO --- [   asgi_gw_0] localstack.request.aws     : AWS sqs.DeleteQueue => 500 (InternalError); DeleteQueueRequest({'QueueUrl': None}, headers={'User-Agent': 'aws-sdk-dotnet-coreclr/3.7.200.18 aws-sdk-dotnet-core/3.7.200.17 .NET_Core/7.0.9 OS/Microsoft_Windows_10.0.22621 ClientAsync', 'amz-sdk-invocation-id': 'aeb4c6dc-5a11-48d0-9e47-fa12ba44d49e', 'amz-sdk-request': 'attempt=1; max=5', 'x-amz-security-token': 'my-AwsSessionToken', 'Host': 'sqs.eu-central-1.amazonaws.com', 'X-Amz-Date': '20230815T202851Z', 'X-Amz-Content-SHA256': '234f83d4860d1a65d3197e883f74f64ea74ddb51defe9f1e5d6d1f592e3d93d5', 'Authorization': 'AWS4-HMAC-SHA256 Credential=my-AwsAccessKeyId/20230815/eu-central-1/sqs/aws4_request, SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;x-amz-date;x-amz-security-token, Signature=169401817cbf42532a02242bde240e6c75ad1fa9d111ff907b037afae39dd449', 'Content-Length': '37', 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'x-localstack-tgt-api': 'sqs', 'x-moto-account-id': '000000000000'}); InternalError(exception while calling sqs.DeleteQueue: Traceback (most recent call last):

Steps to Reproduce the Problem

Running "AmazonSqsService_Should_Delete_A_Queue" in functional tests against LocalStack v2.2

Specifications

Blind-Striker commented 1 year ago

Fixed by LocalStack with https://github.com/localstack/localstack/pull/8962