From a339f3ae700dd2f3793a52cef79ee335bd3d20c6 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 9 Sep 2026 21:31:33 +0100 Subject: [PATCH] docs(lambda): correct the FunctionName charset claim in CodeStore (#3310) The Javadoc on getVersionsPath, and the matching comment in CodeStoreTest, say floci "does not restrict the character set of FunctionName today, only that it is non-blank". That is wrong. LambdaArnUtils.validateName has validated the name since #450, against [a-zA-Z0-9-_.]+ with a 256 character ceiling. The conclusion both comments draw is unaffected: a dot is an accepted character, so "foo.v1" really is a function a user can create, and it really would have collided with a ".v" sibling directory. Only the stated reason was wrong, and it misdescribes the validation a reader would go on to look for. Both now name the actual pattern and point at #3238, which tracks the divergence from the live service. Comments only. No behaviour change. Refs #3238 --- .../floci/services/lambda/zip/CodeStore.java | 11 ++++++----- .../floci/services/lambda/zip/CodeStoreTest.java | 13 +++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/io/github/hectorvent/floci/services/lambda/zip/CodeStore.java b/src/main/java/io/github/hectorvent/floci/services/lambda/zip/CodeStore.java index f937601bdc..4c12cf026e 100644 --- a/src/main/java/io/github/hectorvent/floci/services/lambda/zip/CodeStore.java +++ b/src/main/java/io/github/hectorvent/floci/services/lambda/zip/CodeStore.java @@ -70,11 +70,12 @@ public class CodeStore { * *

The {@link #VERSIONS_DIR_SUFFIX} is what keeps that sibling from colliding with a real * function. {@link #sanitizeName} maps every name into {@code [a-zA-Z0-9_.-]}, so no function - * can produce a directory name containing {@code @}, whatever it is called. Floci does not - * restrict the character set of {@code FunctionName} today, only that it is non-blank, so a - * plainer {@code .v} sibling carried no such guarantee: a function genuinely named - * {@code foo.v1} owns the exact directory {@code foo}'s version 1 would otherwise claim, and - * deleting either one silently corrupts the other. + * can produce a directory name containing {@code @}, whatever it is called. A plainer + * {@code .v} sibling carried no such guarantee, because a dot is an accepted character + * in a function name: {@code LambdaArnUtils} validates against {@code [a-zA-Z0-9-_.]+}, which is + * wider than the live service (issue #3238). So a function genuinely named {@code foo.v1} owns + * the exact directory {@code foo}'s version 1 would otherwise claim, and deleting either one + * silently corrupts the other. */ public Path getVersionsPath(String accountId, String region, String functionName) { return baseDir.resolve(sanitizeName(accountId)) diff --git a/src/test/java/io/github/hectorvent/floci/services/lambda/zip/CodeStoreTest.java b/src/test/java/io/github/hectorvent/floci/services/lambda/zip/CodeStoreTest.java index 2b8c6a6f2b..9c7ee1d773 100644 --- a/src/test/java/io/github/hectorvent/floci/services/lambda/zip/CodeStoreTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/lambda/zip/CodeStoreTest.java @@ -122,12 +122,13 @@ class CodeStoreTest { @Test void aVersionDirectoryCannotCollideWithAnotherFunctionsOwnDirectory(@TempDir Path baseDir) throws IOException { - // Floci does not restrict the character set of FunctionName today, only that it is - // non-blank, so "foo.v1" is a function a user can genuinely create. A ".v" sibling - // naming scheme handed it the exact directory version 1 of "foo" would claim, so deleting - // either function silently corrupted the other. The suffix used instead is outside the - // character set sanitizeName can emit, which makes the two namespaces disjoint by - // construction rather than by a prefix match that has to guess where the name ends. + // A dot is an accepted character in a function name: LambdaArnUtils validates against + // [a-zA-Z0-9-_.]+, which is wider than the live service (issue #3238), so "foo.v1" is a + // function a user can genuinely create. A ".v" sibling naming scheme handed it the + // exact directory version 1 of "foo" would claim, so deleting either function silently + // corrupted the other. The suffix used instead is outside the character set sanitizeName + // can emit, which makes the two namespaces disjoint by construction rather than by a prefix + // match that has to guess where the name ends. CodeStore store = new CodeStore(baseDir); writeHandler(store.getVersionCodePath(ACCOUNT_A, REGION, "foo", "1"), "foo-v1"); writeHandler(store.getCodePath(ACCOUNT_A, REGION, "foo.v1"), "other-function");