Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

docs(lambda): say blank LogGroup is deliberately read as not supplied (#3271)

Allen Sanborn27d2de0479aa
diff --git a/src/main/java/io/github/hectorvent/floci/services/lambda/LambdaService.java b/src/main/java/io/github/hectorvent/floci/services/lambda/LambdaService.java
index 38a24a1b16..9a94894dfa 100644
--- a/src/main/java/io/github/hectorvent/floci/services/lambda/LambdaService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/lambda/LambdaService.java
@@ -2266,6 +2266,16 @@ public class LambdaService implements ResourceProvider {
/**
* LogGroup is the one LoggingConfig member with a documented length and character
* constraint rather than an enum: 1-512 characters, {@code [.\-_/#A-Za-z0-9]+}.
+ *
+ * <p>A blank LogGroup (empty or whitespace-only) is deliberately read as "not supplied"
+ * rather than as a violation of that 1-character minimum, so {@link #applyLoggingConfig}
+ * falls back to the {@code /aws/lambda/} default exactly as it does for an absent member.
+ * The minimum is real in the service model, but botocore enforces it client side, so an
+ * empty LogGroup never reaches the wire from an SDK caller and nobody has observed what
+ * the service itself answers to one. Rejecting it here would be a 400 we inferred rather
+ * than measured; accepting it costs a caller nothing. That leniency is pinned by
+ * {@code LambdaVpcSnapStartLoggingIntegrationTest}, so a later reader who wants the
+ * minimum enforced has to change the decision, not just the guard.
*/
private static void validateLogGroup(Object value) {
if (!(value instanceof String group) || group.isBlank()) {
diff --git a/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaVpcSnapStartLoggingIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaVpcSnapStartLoggingIntegrationTest.java
index dd66994ee8..400e25041a 100644
--- a/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaVpcSnapStartLoggingIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaVpcSnapStartLoggingIntegrationTest.java
@@ -435,6 +435,45 @@ class LambdaVpcSnapStartLoggingIntegrationTest {
.body("__type", equalTo("ValidationException"));
}
+ /**
+ * The service model gives LogGroup a 1-character minimum, so an empty string is a length
+ * violation on paper. Floci reads it as "not supplied" instead: botocore enforces that
+ * minimum client side, so an empty LogGroup never reaches the wire from an SDK caller and
+ * nobody has observed what AWS answers to one. This pins the leniency rather than a 400 we
+ * would only have inferred.
+ */
+ @Test
+ void blankLogGroupIsReadAsNotSuppliedRatherThanRejected() {
+ createFunction("logging-blank-group-fn", """
+ ,
+ "LoggingConfig": {"LogGroup": ""}""");
+
+ given()
+ .when()
+ .get(BASE_PATH + "/functions/logging-blank-group-fn/configuration")
+ .then()
+ .statusCode(200)
+ .body("LoggingConfig.LogGroup", equalTo("/aws/lambda/logging-blank-group-fn"));
+ }
+
+ @Test
+ void whitespaceOnlyLogGroupIsReadAsNotSuppliedRatherThanRejected() {
+ // The guard is isBlank(), not isEmpty(), so a whitespace-only value takes the same
+ // deliberate not-supplied path as "". Pinned separately because the javadoc claims
+ // both and an empty-string-only test would let isBlank() be narrowed to isEmpty()
+ // without anything going red.
+ createFunction("logging-ws-group-fn", """
+ ,
+ "LoggingConfig": {"LogGroup": " "}""");
+
+ given()
+ .when()
+ .get(BASE_PATH + "/functions/logging-ws-group-fn/configuration")
+ .then()
+ .statusCode(200)
+ .body("LoggingConfig.LogGroup", equalTo("/aws/lambda/logging-ws-group-fn"));
+ }
+
@Test
void loggingConfigRejectsLogGroupLongerThanFiveHundredTwelveCharacters() {
String tooLong = "a".repeat(513);