fix(lambda): resolve handler paths with a leading "./" against the package (#1575)

A Node/file-based handler can be given with a leading "./" — e.g.
"./v1/lambda-handlers/entry.handler", as the terraform-aws-modules/lambda module
(and DPS) emit. resolveHandlerFilePath stripped only the ".handler" export
suffix, leaving "./v1/lambda-handlers/entry", which never matched the
deployment-package entry "v1/lambda-handlers/entry.js" (stored without the
"./"). CreateFunction then rejected the function with
"Handler file '...' not found in deployment package".

Normalize a leading "./" away before matching the handler against the package.
This commit is contained in:
Alex Banna authored and GitHub committed 2026-06-25 18:04:25 -05:00
1 parent ad1cc22c19
commit 0a806f7382
2 files changed
+43

No files matched your search

@@ -279,6 +279,43 @@ class LambdaIntegrationTest {
given().delete(BASE_PATH + "/functions/large-zip-fn");
}
@Test
@Order(15)
void createFunctionWithDotSlashNestedHandler() throws Exception {
// A handler given with a leading "./" and a nested path (e.g.
// "./v1/lambda-handlers/entry.handler") must resolve against the zip entry
// "v1/lambda-handlers/entry.js" — the "./" prefix is normalized away.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (ZipOutputStream zos = new ZipOutputStream(baos)) {
zos.putNextEntry(new ZipEntry("v1/lambda-handlers/entry.js"));
zos.write("exports.handler = async () => ({ ok: true });".getBytes());
zos.closeEntry();
}
String base64Zip = Base64.getEncoder().encodeToString(baos.toByteArray());
given()
.contentType("application/json")
.body("""
{
"FunctionName": "dotslash-fn",
"Runtime": "nodejs20.x",
"Role": "arn:aws:iam::000000000000:role/lambda-role",
"Handler": "./v1/lambda-handlers/entry.handler",
"Code": {
"ZipFile": "%s"
}
}
""".formatted(base64Zip))
.when()
.post(BASE_PATH + "/functions")
.then()
.statusCode(201)
.body("FunctionName", equalTo("dotslash-fn"));
// cleanup
given().delete(BASE_PATH + "/functions/dotslash-fn");
}
// ── ImageConfig ───────────────────────────────────────────────────────────
@Test