Files
floci/src
David 231c0972b0 fix(cloudformation): fail the stack when Lambda S3 code cannot be read (#2650)
* fix(cloudformation): fail the stack when Lambda S3 code cannot be read

resolveLambdaCode probed Code.S3Bucket/S3Key only to decide whether to use
it, and treated any failure as "no code available", falling through to the
built-in default handler. A fallback default is sound only when the input
is absent; applying it to an input that is present but unusable turns an
explicit user intent into a silent substitution.

With Handler: index.handler -- the stub's own handler -- the stack reached
CREATE_COMPLETE and the function served the stub's canned 200 for every
request, with nothing in the API surface saying the declared code was never
deployed. With any other handler the resource instead failed with "Handler
file '<x>' not found in deployment package", naming a handler that is
correct in the template and present in the package that was never fetched.

Throw ValidationError naming the bucket, the key and the underlying S3
error, so the resource fails and the stack rolls back as real
CloudFormation does. The default handler is kept for its legitimate case, a
template that supplies no Code block at all.

Note this changes outcomes: stacks that previously completed against
unreadable code now fail.

Closes #2648

* fix(cloudformation): allow opting back in to the Lambda stub fallback

Adds floci.services.cloudformation.allow-stub-lambda-code, defaulting to
false, so failing the stack on unreadable Lambda code stays the default
while a stack that deliberately leaves its packages unbuilt can opt back
in to the previous stub handler rather than break on upgrade. Requested
during review of the parent change.

The knob lives on EmulatorConfig.CloudFormationServiceConfig and in both
the main and test application.yml. Its javadoc records what enabling it
costs: the stack reports CREATE_COMPLETE while serving a placeholder that
returns a canned 200, so it cannot be used to verify the real function.

Reading the flag means the provisioner needs EmulatorConfig, and that
constructor parameter reaches 13 unit tests that build it positionally.
Those pass null, so the read is null safe: a provisioner built without
config gets the documented default, which is the strict behaviour.

The opt in path is covered by its own top level test class rather than a
nested one. A nested class carrying @TestProfile compiles and passes when
targeted directly, but Surefire discovers test classes by file name and
skips it in a full run.
2026-08-28 13:24:53 -04:00
..