feat(lambda): store DurableConfig on functions (execution later) (#5007)

* feat(lambda): accept and echo DurableConfig on functions

CreateFunction and UpdateFunctionConfiguration take DurableConfig, PublishVersion snapshots it, and every read echoes it. ExecutionTimeout is required on create, RetentionPeriodInDays defaults to 14, a durable function's Timeout defaults to min(ExecutionTimeout, 900) and its logging to JSON. Update merges the members, and a function created without DurableConfig cannot gain one. KMSKeyArn is validated against its pattern and stored, the key itself is not looked up.

* chore(lambda): trim the DurableConfig tests to one case per rule

* feat(lambda): durable functions log in JSON format only

A durable function rejects LogFormat Text on create and update, and a LoggingConfig without LogFormat reads back as JSON. An empty KMSKeyArn means no key.

* chore(lambda): let the logging helpers own the durable JSON rule

validateLoggingConfig and applyLoggingConfig take the durable flag, so a durable function's default format and the Text rejection live in one place and a LoggingConfig without LogFormat keeps its log levels. applyDurableConfig sets the retention default and merges, and the test uses chainable helpers.

* chore(lambda): say why the durable compat test ignores a failed cleanup
This commit is contained in:
TATSUNO “Taz” Yasuhiro authored and GitHub committed 2026-10-03 14:35:12 -05:00
1 parent 583b2baf7f
commit 823f8751de
8 files changed
+483 -9

No files matched your search

@@ -275,4 +275,57 @@ class LambdaFunctionConfigTest {
} catch (Exception ignored) {}
}
}
@Test
@Order(7)
@DisplayName("DurableConfig round-trips via create, update and get")
void durableConfigRoundTrips() {
String durableFn = TestFixtures.uniqueName("fn-durable");
try {
CreateFunctionResponse createResp = lambda.createFunction(CreateFunctionRequest.builder()
.functionName(durableFn)
.runtime(Runtime.NODEJS20_X)
.role(ROLE)
.handler("index.handler")
.code(FunctionCode.builder()
.zipFile(SdkBytes.fromByteArray(LambdaUtils.minimalZip()))
.build())
.durableConfig(DurableConfig.builder().executionTimeout(3600).build())
.build());
assertThat(createResp.durableConfig().executionTimeout()).isEqualTo(3600);
assertThat(createResp.durableConfig().retentionPeriodInDays())
.as("RetentionPeriodInDays defaults to 14")
.isEqualTo(14);
assertThat(createResp.timeout())
.as("Timeout of a durable function defaults to the 15 minute cap")
.isEqualTo(900);
UpdateFunctionConfigurationResponse updateResp = lambda.updateFunctionConfiguration(
UpdateFunctionConfigurationRequest.builder()
.functionName(durableFn)
.durableConfig(DurableConfig.builder().retentionPeriodInDays(7).build())
.build());
assertThat(updateResp.durableConfig().executionTimeout())
.as("a member left out of the update keeps its value")
.isEqualTo(3600);
assertThat(updateResp.durableConfig().retentionPeriodInDays()).isEqualTo(7);
GetFunctionConfigurationResponse getResp = lambda.getFunctionConfiguration(
GetFunctionConfigurationRequest.builder().functionName(durableFn).build());
assertThat(getResp.durableConfig().retentionPeriodInDays()).isEqualTo(7);
GetFunctionConfigurationResponse plain = lambda.getFunctionConfiguration(
GetFunctionConfigurationRequest.builder().functionName(FN).build());
assertThat(plain.durableConfig())
.as("a function created without DurableConfig has none")
.isNull();
} finally {
try {
lambda.deleteFunction(DeleteFunctionRequest.builder().functionName(durableFn).build());
} catch (Exception ignored) {
// Cleanup only. A failed delete must not hide the test result.
}
}
}
}