Skip to content

armgit / floci

Public Imported from GitHub
0

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

docs(lambda): correct the FunctionName charset claim in CodeStore (#3310)

Davida339f3ae700d
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 {
*
* <p>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 <name>.v<n>} 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 <name>.v<n>} 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 "<name>.v<n>" 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 "<name>.v<n>" 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");