mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(sqs): skip JSON null tag/attribute values instead of storing literal "null" (#905)
* fix(sqs): skip JSON null values in TagQueue tags and attribute maps
JsonNode.asText() returns the literal string "null" for explicit JSON
null values. This caused TagQueue with {"Tags":{"NullTag":null}} to
store the four-character string "null" as the tag value, surfacing on
the wire as <Value>null</Value> when read back via ListQueueTags.
Same path is used for CreateQueue / SetQueueAttributes attribute maps,
where a null-valued attribute would have stored the same literal.
Skip null/missing JsonNode values in jsonNodeToMap so the absent key
round-trips as absent rather than as the string "null".
* fix(sqs): reject JSON null tag/attribute values with InvalidParameterValue
Match real AWS behavior: return HTTP 400 InvalidParameterValue with
'the parameter "value" may not be null' when a JSON 1.0 TagQueue,
CreateQueue, or SetQueueAttributes request contains a null map value,
rather than silently skipping the entry.
Adds regression coverage for TagQueue, CreateQueue (tags + attributes),
and SetQueueAttributes.
This commit is contained in:
1 parent
337b35c938
commit
aec85f993a
2 files changed
+93
-1
No files matched your search
@@ -289,6 +289,91 @@ class SqsJsonProtocolTest {
|
||||
.body("Messages[0].Attributes.ApproximateFirstReceiveTimestamp", notNullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
void tagQueueWithJsonNullValueIsRejected() {
|
||||
String tagBody = "{\"QueueUrl\":\"" + queueUrl + "\","
|
||||
+ "\"Tags\":{\"NullTag\":null,\"RealTag\":\"value\"}}";
|
||||
|
||||
given()
|
||||
.contentType(CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AmazonSQS.TagQueue")
|
||||
.body(tagBody)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("InvalidParameterValue"))
|
||||
.body("message", equalTo("the parameter 'value' may not be null"));
|
||||
|
||||
String listBody = "{\"QueueUrl\":\"" + queueUrl + "\"}";
|
||||
|
||||
given()
|
||||
.contentType(CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AmazonSQS.ListQueueTags")
|
||||
.body(listBody)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Tags.NullTag", nullValue())
|
||||
.body("Tags.RealTag", nullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
void createQueueWithJsonNullTagValueIsRejected() {
|
||||
String body = "{\"QueueName\":\"" + QUEUE_NAME + "-null-tag\","
|
||||
+ "\"tags\":{\"NullTag\":null}}";
|
||||
|
||||
given()
|
||||
.contentType(CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AmazonSQS.CreateQueue")
|
||||
.body(body)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("InvalidParameterValue"))
|
||||
.body("message", equalTo("the parameter 'value' may not be null"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
void createQueueWithJsonNullAttributeValueIsRejected() {
|
||||
String body = "{\"QueueName\":\"" + QUEUE_NAME + "-null-attr\","
|
||||
+ "\"Attributes\":{\"DelaySeconds\":null}}";
|
||||
|
||||
given()
|
||||
.contentType(CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AmazonSQS.CreateQueue")
|
||||
.body(body)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("InvalidParameterValue"))
|
||||
.body("message", equalTo("the parameter 'value' may not be null"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
void setQueueAttributesWithJsonNullValueIsRejected() {
|
||||
String body = "{\"QueueUrl\":\"" + queueUrl + "\","
|
||||
+ "\"Attributes\":{\"DelaySeconds\":null}}";
|
||||
|
||||
given()
|
||||
.contentType(CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AmazonSQS.SetQueueAttributes")
|
||||
.body(body)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("InvalidParameterValue"))
|
||||
.body("message", equalTo("the parameter 'value' may not be null"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(8)
|
||||
void deleteQueueViaQueueUrlPath() {
|
||||
|
||||
Reference in new issue
Block a user