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

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

LogGroup carries a 1-512 length constraint, so an empty string is a
length violation on paper, yet validateLogGroup exempts blank and
applyLoggingConfig then falls back to the /aws/lambda/ default. That
looked like the guard missing the minimum.

It is a choice, not an oversight. botocore enforces the 1-character
minimum client side, so an empty LogGroup never reaches the wire from
an SDK caller and nobody has observed what the service answers to one.
A 400 here would be inferred rather than measured, and rejecting a
request we have never seen AWS reject is the expensive side of the
trade; accepting it costs a caller nothing.

Say that in the javadoc, and pin the leniency with a test so a later
reader who wants the minimum enforced has to change the decision
rather than just the guard.

* test(lambda): pin the whitespace-only LogGroup case, not just the empty one

The javadoc says blank means "empty or whitespace-only" and the guard is isBlank(),
but the only test passed "". Narrowing isBlank() to isEmpty() left the suite green,
so half the documented contract was unpinned.

Adds the whitespace-only case. Verified load-bearing: with isEmpty() in place of
isBlank() this test alone fails, and nothing else does.
This commit is contained in:
Allen Sanborn authored and GitHub committed 2026-09-08 15:35:35 -04:00
1 parent b6080ea4ff
commit 27d2de0479
2 files changed
+49

No files matched your search

@@ -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()) {
@@ -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);