fix: SQS tags set at CreateQueue not returned by ListQueueTags (#747)

Tags passed to CreateQueue were silently dropped in both the Query
and JSON protocol handlers — neither extracted the Tags parameter
before calling sqsService.createQueue().

Changes:
- SqsQueryHandler: extract Tag.N.Key/Value params and pass to service
- SqsJsonHandler: read both 'Tags' and 'tags' fields (botocore sends
  lowercase 'tags' for CreateQueue but uppercase 'Tags' for TagQueue)
- SqsService: add createQueue overload accepting tags; existing 2-arg
  and 3-arg overloads delegate with null tags (no callers broken)

Closes #699
This commit is contained in:
Dixit R Jain authored and GitHub committed 2026-05-08 17:17:36 -05:00
1 parent 3ae5c7b467
commit 1ffe905271
6 files changed
+101 -3

No files matched your search

@@ -66,7 +66,11 @@ public class SqsJsonHandler {
private Response handleCreateQueue(JsonNode request, String region) {
String queueName = request.path("QueueName").asText(null);
Map<String, String> attributes = jsonNodeToMap(request.path("Attributes"));
Queue queue = sqsService.createQueue(queueName, attributes, region);
// Botocore sends "tags" (lowercase) for CreateQueue but "Tags" (uppercase) for TagQueue.
// Merge both to handle any client regardless of casing.
Map<String, String> tags = new HashMap<>(jsonNodeToMap(request.path("Tags")));
tags.putAll(jsonNodeToMap(request.path("tags")));
Queue queue = sqsService.createQueue(queueName, attributes, tags, region);
ObjectNode response = objectMapper.createObjectNode();
response.put("QueueUrl", queue.getQueueUrl());
@@ -64,7 +64,8 @@ public class SqsQueryHandler {
private Response handleCreateQueue(MultivaluedMap<String, String> params, String region) {
String queueName = getParam(params, "QueueName");
Map<String, String> attributes = extractAttributes(params);
Queue queue = sqsService.createQueue(queueName, attributes, region);
Map<String, String> tags = extractTags(params);
Queue queue = sqsService.createQueue(queueName, attributes, tags, region);
String result = new XmlBuilder().elem("QueueUrl", queue.getQueueUrl()).build();
return Response.ok(AwsQueryResponse.envelope("CreateQueue", null, result)).build();
@@ -439,6 +440,17 @@ public class SqsQueryHandler {
return attributes;
}
private Map<String, String> extractTags(MultivaluedMap<String, String> params) {
Map<String, String> tags = new HashMap<>();
for (int i = 1; ; i++) {
String key = getParam(params, "Tag." + i + ".Key");
String value = getParam(params, "Tag." + i + ".Value");
if (key == null) break;
tags.put(key, value);
}
return tags;
}
Response xmlErrorResponse(String code, String message, int status) {
return AwsQueryResponse.error(code, message, AwsNamespaces.SQS, status);
}
@@ -153,10 +153,14 @@ public class SqsService {
}
public Queue createQueue(String queueName, Map<String, String> attributes) {
return createQueue(queueName, attributes, regionResolver.getDefaultRegion());
return createQueue(queueName, attributes, null, regionResolver.getDefaultRegion());
}
public Queue createQueue(String queueName, Map<String, String> attributes, String region) {
return createQueue(queueName, attributes, null, region);
}
public Queue createQueue(String queueName, Map<String, String> attributes, Map<String, String> tags, String region) {
boolean fifoRequested = attributes != null && "true".equalsIgnoreCase(attributes.get("FifoQueue"));
boolean hasFifoSuffix = queueName != null && queueName.endsWith(".fifo");
@@ -199,6 +203,9 @@ public class SqsService {
if (attributes != null) {
queue.getAttributes().putAll(attributes);
}
if (tags != null) {
queue.getTags().putAll(tags);
}
// Set default attributes
queue.getAttributes().putIfAbsent("VisibilityTimeout", String.valueOf(defaultVisibilityTimeout));
queue.getAttributes().putIfAbsent("MaximumMessageSize", String.valueOf(maxMessageSize));