fix(sqs): refuse a FifoQueue attribute on a standard queue (#8898)

CreateQueue now refuses a FifoQueue attribute, even false, on a queue whose name does not end in .fifo, with InvalidAttributeName "Unknown Attribute FifoQueue." as AWS does, before any queue is stored. An AWS::SQS::Queue declaring FifoQueue: false now fails and rolls back with the same message, while a FifoQueue dropped through AWS::NoValue still leaves a standard queue.

Closes #8788
This commit is contained in:
Niels Kootstra authored and GitHub committed 2026-11-18 20:04:05 -04:00
1 parent 1d8499e837
commit 9d39f2941a
4 files changed
+95

No files matched your search

+2
View File
@@ -101,6 +101,8 @@ aws sqs set-queue-attributes \
`GetQueueAttributes` with `--attribute-names All` returns the set AWS returns for a standard queue: `QueueArn`, `CreatedTimestamp`, `LastModifiedTimestamp`, `ApproximateNumberOfMessages`, `ApproximateNumberOfMessagesNotVisible`, `ApproximateNumberOfMessagesDelayed`, `VisibilityTimeout`, `MaximumMessageSize`, `MessageRetentionPeriod`, `DelaySeconds`, `ReceiveMessageWaitTimeSeconds` and `SqsManagedSseEnabled`. `Policy`, `RedrivePolicy` and `KmsMasterKeyId` appear only once set, and FIFO queues also report `FifoQueue` and `ContentBasedDeduplication`.
A standard queue has no `FifoQueue` attribute: `CreateQueue` refuses one, even `FifoQueue=false`, with `InvalidAttributeName` (`Unknown Attribute FifoQueue.`), as AWS does. An `AWS::SQS::Queue` declaring `FifoQueue: false` fails its stack the same way; leave the property out for a standard queue.
`MaximumMessageSize` defaults to `1048576` bytes, the AWS default and maximum since August 2025, when AWS raised both from `262144`. `CreateQueue` and `SetQueueAttributes` reject values outside 1024 to 1048576 with `InvalidAttributeValue`; raising `FLOCI_SERVICES_SQS_MAX_MESSAGE_SIZE` above the AWS maximum raises that accepted ceiling with it. Lowering the variable below 1048576 only changes the default a new queue receives: the accepted ceiling stays at the AWS maximum, so a queue can still be set to `1048576` explicitly.
`DelaySeconds` must be 0 to 900, both on a message and as a queue attribute: `SendMessage` rejects other values with `InvalidParameterValue` (in `SendMessageBatch` only that entry fails), and `CreateQueue` and `SetQueueAttributes` reject them with `InvalidAttributeValue`.
@@ -733,6 +733,10 @@ public class SqsService implements Resettable, ResourceProvider {
throw new AwsException("InvalidParameterValue",
"The name of a FIFO queue can only end with '.fifo'.", 400);
}
if (!hasFifoSuffix && attributes != null && attributes.containsKey("FifoQueue")) {
// A standard queue has no FifoQueue attribute, so SQS refuses even an explicit false.
throw new AwsException("InvalidAttributeName", "Unknown Attribute FifoQueue.", 400);
}
if (hasFifoSuffix && !fifoRequested) {
// Auto-set FifoQueue attribute when name ends with .fifo
attributes = attributes == null ? new HashMap<>() : new HashMap<>(attributes);
@@ -5,10 +5,13 @@ import io.floci.aws.testing.CfnStackWaits;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Map;
import static io.restassured.RestAssured.given;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -27,6 +30,8 @@ class CloudFormationSqsQueuePropertiesIntegrationTest {
private static final String NO_VALUE_STACK = "cfn-sqs-queue-no-value";
private static final String SSE_STACK = "cfn-sqs-queue-sse";
private static final String FIFO_STACK = "cfn-sqs-queue-fifo";
private static final String FIFO_FALSE_STACK = "cfn-sqs-queue-fifo-false";
private static final String FIFO_NO_VALUE_STACK = "cfn-sqs-queue-fifo-no-value";
@Test
void declaredPropertiesReachTheQueueAndDroppedOnesReturnToTheirDefaults() {
@@ -222,6 +227,56 @@ class CloudFormationSqsQueuePropertiesIntegrationTest {
cloudFormation(FIFO_STACK, "DeleteStack", null);
}
@Test
void aStandardQueueDeclaringFifoQueueFalseFailsTheStackAsAwsDoes() {
String template = """
{
"Resources": {
"Queue": {"Type": "AWS::SQS::Queue", "Properties": {"FifoQueue": false}}
}
}
""";
cloudFormation(FIFO_FALSE_STACK, "CreateStack", template);
CfnStackWaits.StackState state = CfnStackWaits.awaitTerminal(FIFO_FALSE_STACK, CFN_AUTH);
assertEquals("ROLLBACK_COMPLETE", state.status(), state.reason());
String events = given()
.contentType("application/x-www-form-urlencoded")
.header("Authorization", CFN_AUTH)
.formParam("Action", "DescribeStackEvents")
.formParam("StackName", FIFO_FALSE_STACK)
.when().post("/").then().statusCode(200).extract().asString();
List<String> failures = XmlParser.extractGroups(events, "member").stream()
.filter(event -> "Queue".equals(event.get("LogicalResourceId"))
&& "CREATE_FAILED".equals(event.get("ResourceStatus")))
.map(event -> event.get("ResourceStatusReason"))
.toList();
assertThat(failures, contains(containsString("Unknown Attribute FifoQueue.")));
cloudFormation(FIFO_FALSE_STACK, "DeleteStack", null);
}
@Test
void aFifoQueueAConditionDropsWithNoValueLeavesAStandardQueue() {
String template = """
{
"Conditions": {"Fifo": {"Fn::Equals": ["yes", "no"]}},
"Resources": {
"Queue": {
"Type": "AWS::SQS::Queue",
"Properties": {"FifoQueue": {"Fn::If": ["Fifo", true, {"Ref": "AWS::NoValue"}]}}
}
},
"Outputs": {"QueueUrl": {"Value": {"Ref": "Queue"}}}
}
""";
cloudFormation(FIFO_NO_VALUE_STACK, "CreateStack", template);
String queueUrl = XmlParser.extractPairs(describeStacks(FIFO_NO_VALUE_STACK, "CREATE_COMPLETE"), "Outputs",
"OutputKey", "OutputValue").get("QueueUrl");
assertFalse(queueAttributes(queueUrl).containsKey("FifoQueue"));
cloudFormation(FIFO_NO_VALUE_STACK, "DeleteStack", null);
}
private static void cloudFormation(String stack, String action, String templateBody) {
if (templateBody == null) {
given()
@@ -0,0 +1,34 @@
package io.floci.aws.services.sqs;
import io.floci.aws.testing.AwsTestClients;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.sqs.SqsClient;
import software.amazon.awssdk.services.sqs.model.InvalidAttributeNameException;
import software.amazon.awssdk.services.sqs.model.QueueAttributeName;
import software.amazon.awssdk.services.sqs.model.QueueDoesNotExistException;
import java.util.Map;
import java.util.UUID;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
/** A standard queue has no FifoQueue attribute, so SQS refuses one even when it says {@code false}. */
@QuarkusTest
class SqsFifoQueueAttributeIntegrationTest {
@Test
void aStandardQueueWithFifoQueueFalseIsRefusedAsAnUnknownAttribute() {
String queueName = "standard-" + UUID.randomUUID().toString().substring(0, 8);
try (SqsClient sqs = AwsTestClients.create(SqsClient.builder(), "test", Region.US_EAST_1)) {
InvalidAttributeNameException refused = assertThrows(InvalidAttributeNameException.class,
() -> sqs.createQueue(r -> r.queueName(queueName)
.attributes(Map.of(QueueAttributeName.FIFO_QUEUE, "false"))));
assertEquals("Unknown Attribute FifoQueue.", refused.awsErrorDetails().errorMessage());
assertThrows(QueueDoesNotExistException.class, () -> sqs.getQueueUrl(r -> r.queueName(queueName)));
}
}
}