mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(dynamodb): match AWS wording and order for Select rejections (#3410)
* fix(dynamodb): match AWS wording and order for Select rejections Query and Scan share one Select validator. It reported Floci wording and checked the rules in the wrong order, so a request breaking both the ProjectionExpression rule and the IndexName rule named the wrong one. The ProjectionExpression conflict is now reported first, and each message names the Select value the way AWS does. The SPECIFIC_ATTRIBUTES message without a projection also matches AWS, which prefixes the error count on Query but not on Scan. Closes 8 TIER 1 and 2 TIER 3 cases in the dynamodb-conformance suite. * test(dynamodb): cover the bare Select message on Scan Scan returns the message without the validation count prefix, Query keeps it. Only the Query side had a handler-level test.
This commit is contained in:
1 parent
be578ac13f
commit
dffe34e133
4 files changed
+64
-8
No files matched your search
+30
@@ -387,6 +387,36 @@ class DynamoDbAccessPathValidatorTest {
|
||||
assertEquals("Query key condition not supported", error.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void namesTheSelectValueWhenRejectingAProjectionExpression() {
|
||||
AwsException allAttributes = assertThrows(AwsException.class,
|
||||
() -> DynamoDbAccessPathValidator.validateSelection(
|
||||
table, tablePath, "ALL_ATTRIBUTES", "sk", null, null));
|
||||
assertEquals("Cannot specify the ProjectionExpression when choosing to get ALL_ATTRIBUTES",
|
||||
allAttributes.getMessage());
|
||||
|
||||
AwsException count = assertThrows(AwsException.class,
|
||||
() -> DynamoDbAccessPathValidator.validateSelection(
|
||||
table, tablePath, "COUNT", "sk", null, null));
|
||||
assertEquals("Cannot specify the ProjectionExpression when choosing to get only the Count",
|
||||
count.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void reportsTheProjectionExpressionConflictBeforeTheMissingIndex() {
|
||||
AwsException both = assertThrows(AwsException.class,
|
||||
() -> DynamoDbAccessPathValidator.validateSelection(
|
||||
table, tablePath, "ALL_PROJECTED_ATTRIBUTES", "sk", null, null));
|
||||
assertEquals("Cannot specify the ProjectionExpression when choosing to get ALL_PROJECTED_ATTRIBUTES",
|
||||
both.getMessage());
|
||||
|
||||
AwsException indexOnly = assertThrows(AwsException.class,
|
||||
() -> DynamoDbAccessPathValidator.validateSelection(
|
||||
table, tablePath, "ALL_PROJECTED_ATTRIBUTES", null, null, null));
|
||||
assertEquals("ALL_PROJECTED_ATTRIBUTES can be used only when Querying using an IndexName",
|
||||
indexOnly.getMessage());
|
||||
}
|
||||
|
||||
private void validateExpression(DynamoDbAccessPath accessPath, String expression) {
|
||||
DynamoDbAccessPathValidator.validateQuery(
|
||||
table, accessPath, null, expression, null, null, null,
|
||||
|
||||
+23
-1
@@ -804,7 +804,29 @@ class DynamoDbIntegrationTest {
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ValidationException"))
|
||||
.body("message", equalTo("Select type SPECIFIC_ATTRIBUTES requires the ProjectionExpression to be provided."));
|
||||
.body("message", equalTo("1 validation error detected: Must specify the AttributesToGet or "
|
||||
+ "ProjectionExpression when choosing to get SPECIFIC_ATTRIBUTES"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
void scanWithSelectSpecificAttributesRequiresProjectionParameters() {
|
||||
given()
|
||||
.header("X-Amz-Target", "DynamoDB_20120810.Scan")
|
||||
.contentType(DYNAMODB_CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"TableName": "TestTable",
|
||||
"Select": "SPECIFIC_ATTRIBUTES"
|
||||
}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ValidationException"))
|
||||
.body("message", equalTo("Must specify the AttributesToGet or "
|
||||
+ "ProjectionExpression when choosing to get SPECIFIC_ATTRIBUTES"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user