mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(lambda): defer handler validation to invocation (#3332)
Fixes #3311
This commit is contained in:
1 parent
8a4c6494ed
commit
8b25e5003d
3 files changed
+18
-53
No files matched your search
@@ -2773,30 +2773,6 @@ public class LambdaService implements ResourceProvider {
|
||||
}
|
||||
}
|
||||
|
||||
// For file-based runtimes, verify handler file exists (skip Java and .NET which use different handler formats)
|
||||
if (fn.getRuntime() != null && !fn.getRuntime().startsWith("java") && !fn.getRuntime().startsWith("dotnet")) {
|
||||
String handlerFile = resolveHandlerFilePath(fn);
|
||||
boolean pythonRuntime = fn.getRuntime().startsWith("python");
|
||||
boolean found;
|
||||
try (var walk = Files.walk(codePath)) {
|
||||
found = walk
|
||||
.filter(Files::isRegularFile)
|
||||
.anyMatch(p -> {
|
||||
String relative = codePath.relativize(p).toString();
|
||||
String withoutExt = relative.contains(".")
|
||||
? relative.substring(0, relative.lastIndexOf('.'))
|
||||
: relative;
|
||||
String normalized = withoutExt.replace('\\', '/');
|
||||
return normalized.equals(handlerFile)
|
||||
|| (pythonRuntime && normalized.equals(handlerFile + "/__init__"));
|
||||
});
|
||||
}
|
||||
if (!found) {
|
||||
throw new AwsException("InvalidParameterValueException",
|
||||
"Handler file '" + handlerFile + "' not found in deployment package", 400);
|
||||
}
|
||||
}
|
||||
|
||||
// Deploy succeeded: keep the exact package so GetFunction can serve
|
||||
// a real Code.Location.
|
||||
storeDeploymentPackage(fn, zipBytes, region);
|
||||
@@ -2895,22 +2871,6 @@ public class LambdaService implements ResourceProvider {
|
||||
extractZipCodeBytes(fn, obj.getData(), region);
|
||||
}
|
||||
|
||||
private String resolveHandlerFilePath(LambdaFunction fn) {
|
||||
String handler = fn.getHandler();
|
||||
int lastDot = handler.lastIndexOf('.');
|
||||
String modulePath = lastDot >= 0 ? handler.substring(0, lastDot) : handler;
|
||||
if (fn.getRuntime().startsWith("python")) {
|
||||
return modulePath.replace('.', '/');
|
||||
}
|
||||
// A file-based handler may be given with a leading "./" (e.g.
|
||||
// "./v1/lambda-handlers/entry.handler"); deployment-package entries are stored without
|
||||
// it, so normalize the prefix away before matching.
|
||||
if (modulePath.startsWith("./")) {
|
||||
modulePath = modulePath.substring(2);
|
||||
}
|
||||
return modulePath;
|
||||
}
|
||||
|
||||
private void applyHotReload(LambdaFunction fn, String hostPath) {
|
||||
if (config == null || !config.services().lambda().hotReload().enabled()) {
|
||||
throw new AwsException("InvalidParameterValueException",
|
||||
|
||||
Reference in new issue
Block a user