Repository: localstack/localstack

Issue:
bug: SQS Fifo does not work (version 0.14.2)
### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current Behavior

I'm on an M1 mac. I had a queue with the same name as the following, but it was not a FIFO queue, so I deleted it and recreated. Although it let me create the queue, it didn't exist when I went to the URL.

So I upgraded from an older version of localstack thinking that might be the problem, however this still doesn't work.

```
awslocal sqs create-queue --queue-name us-east-1-dev-recorder-request.fifo --attributes FifoQueue=true
{
    "QueueUrl": "http://localhost:4566/000000000000/us-east-1-dev-recorder-request.fifo"
}
```

This appears to work and the url shows up when running list-queues, however going to the URL shows "no such bucket"

```
awslocal --endpoint-url=http://localhost:4566 sqs create-queue --queue-name bleebloo
```

This does work however without making a Fifo queue. Am I doing something wrong? This seems like it should work fine. I've tried using different names, but no fifo queues work.



### Expected Behavior

`awslocal sqs create-queue --queue-name us-east-1-dev-recorder-request.fifo --attributes FifoQueue=true`

This should create a queue that can be accessed at the returned URL.

### How are you starting LocalStack?

With a docker-compose file

### Steps To Reproduce

```
services:
  localstack:
    image: localstack/localstack:0.14.2
    ports:
      - "4566:4566"
    environment:
      SERVICES: s3,sqs
      DATA_DIR: /tmp/localstack/data
      DOCKER_HOST: unix:///var/run/docker.sock
   volumes:
         - "./tmp/localstack:/tmp/localstack"
         - "/var/run/docker.sock:/var/run/docker.sock"
         
#### Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

`awslocal sqs create-queue --queue-name us-east-1-dev-recorder-request.fifo --attributes FifoQueue=true`


### Environment

```markdown
- OS: macOS Monteray 12.0.1
- LocalStack: 0.14.2
```


### Anything else?

http://localhost:4566/000000000000/test.fifo

For example after creating a test.fifo queue:

```
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>NoSuchBucket</Code>
<Message>The specified bucket does not exist</Message>
<BucketName>000000000000</BucketName>
<RequestID>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestID>
</Error>
```


Discussion:
Welcome to LocalStack! Thanks for reporting your first issue and our team will be working towards fixing the issue for you or reach out for more background information. We recommend joining our [Slack Community](https://localstack.cloud/contact/) for real-time help and drop a message to LocalStack Pro Support if you are a Pro user! If you are willing to contribute towards fixing this issue, please have a look at our [contributing guidelines](https://github.com/localstack/.github/blob/main/CONTRIBUTING.md) and our [developer guide](https://docs.localstack.cloud/developer-guide/).
```
awslocal sqs get-queue-attributes --queue-url "http://localhost:4566/000000000000/us-east-1-dev-test.fifo" --attribute-names All

{
    "Attributes": {
        "ApproximateNumberOfMessages": "0",
        "ApproximateNumberOfMessagesDelayed": "0",
        "ApproximateNumberOfMessagesNotVisible": "0",
        "CreatedTimestamp": "1650329310.341673",
        "DelaySeconds": "0",
        "LastModifiedTimestamp": "1650329310.341673",
        "MaximumMessageSize": "262144",
        "MessageRetentionPeriod": "345600",
        "QueueArn": "arn:aws:sqs:us-east-1:000000000000:us-east-1-dev-test.fifo",
        "ReceiveMessageWaitTimeSeconds": "0",
        "VisibilityTimeout": "30",
        "ContentBasedDeduplication": "false",
        "DeduplicationScope": "queue",
        "FifoQueue": "true",
        "FifoThroughputLimit": "perQueue"
    }
}
```

This also works?

and now sending a message is working? I guess it just doesn't display correctly in the browser.

Resolving patch:
diff --git a/localstack/services/sqs/sqs_listener.py b/localstack/services/sqs/sqs_listener.py
--- a/localstack/services/sqs/sqs_listener.py
+++ b/localstack/services/sqs/sqs_listener.py
@@ -278,7 +278,7 @@ def validate_empty_message_batch(data, req_data):
 
 def is_sqs_queue_url(url):
     path = path_from_url(url).partition("?")[0]
-    return re.match(r"^/(queue|%s)/[a-zA-Z0-9_-]+$" % constants.TEST_AWS_ACCOUNT_ID, path)
+    return re.match(r"^/(queue|%s)/[a-zA-Z0-9_-]+(.fifo)?$" % constants.TEST_AWS_ACCOUNT_ID, path)
 
 
 class ProxyListenerSQS(PersistingProxyListener):


Test patch:
diff --git a/tests/integration/test_sqs.py b/tests/integration/test_sqs.py
--- a/tests/integration/test_sqs.py
+++ b/tests/integration/test_sqs.py
@@ -678,7 +678,7 @@ def test_fifo_queue_requires_suffix(self, sqs_create_queue):
         e.match("InvalidParameterValue")
 
     @pytest.mark.skipif(
-        os.environ.get("PROVIDER_OVERRIDE_SQS") != "asf",
+        config.SERVICE_PROVIDER_CONFIG.get_provider("sqs") != "asf",
         reason="New provider test which isn't covered by old one",
     )
     def test_standard_queue_cannot_have_fifo_suffix(self, sqs_create_queue):
@@ -1042,7 +1042,8 @@ def test_dead_letter_queue_max_receive_count(self, sqs_client, sqs_create_queue)
         )
 
     @pytest.mark.skipif(
-        os.environ.get("PROVIDER_OVERRIDE_SQS") != "asf", reason="Currently fails for moto provider"
+        config.SERVICE_PROVIDER_CONFIG.get_provider("sqs") != "asf",
+        reason="Currently fails for moto provider",
     )
     def test_dead_letter_queue_chain(self, sqs_client, sqs_create_queue):
         # test a chain of 3 queues, with DLQ flow q1 -> q2 -> q3
@@ -1600,7 +1601,7 @@ def test_deduplication_interval(self, sqs_client, sqs_create_queue):
         )[0].get("MD5OfBody")
 
     @pytest.mark.skipif(
-        os.environ.get("PROVIDER_OVERRIDE_SQS") != "asf",
+        config.SERVICE_PROVIDER_CONFIG.get_provider("sqs") != "asf",
         reason="New provider test which isn't covered by old one",
     )
     def test_sse_attributes_are_accepted(self, sqs_client, sqs_create_queue):
@@ -1620,6 +1621,19 @@ def test_sse_attributes_are_accepted(self, sqs_client, sqs_create_queue):
             assert k in keys
             assert attributes[k] == result_attributes[k]
 
+    @pytest.mark.skipif(
+        config.SERVICE_PROVIDER_CONFIG.get_provider("sqs") == "asf",
+        reason="this behaviour needs to be re-evaluated",
+    )
+    def test_call_fifo_queue_url(self, sqs_client, sqs_create_queue):
+        queue_name = f"queue-{short_uid()}.fifo"
+        queue_url = sqs_create_queue(QueueName=queue_name, Attributes={"FifoQueue": "true"})
+
+        assert queue_url.endswith(".fifo")
+        response = requests.get(queue_url)
+        assert response.ok
+        assert queue_url in response.text
+
 
 def get_region():
     return os.environ.get("AWS_DEFAULT_REGION") or TEST_REGION