Repository navigation
Description
Found while implementing #1035, whose fourth acceptance criterion asks for "a Docker-gated test
that an invoke after UpdateFunctionCode runs the new code". That test cannot be written, and the
reason is worth recording rather than leaving as a gap someone else rediscovers.
What happens
startZIPContainer (emulator/lambda_exec.go:139-190) writes the deployment package into a temp
directory as a single file and mounts the directory into the container:
if writeErr := os.WriteFile(dir+"/function.zip", zipBytes, 0600); writeErr != nil {
...
"-v", dir + ":/var/task:ro",Nothing extracts the archive — no archive/zip reader exists outside
lambda_code_size_test.go, which uses one to assert on stored bytes. The AWS Lambda runtime
interface expects /var/task to hold the module tree, so a container started this way sees one
file named function.zip and no index.py. index.handler cannot be imported whatever the ZIP
contains, so every invoke down this path is a function error rather than the caller's result.
The image path (startImageContainer, :192-225) is different and does work as far as it goes:
the code is inside the image, which substrate does not build. So the ZIP path — the one every
CreateFunction with an inline or S3 package takes — is the one that cannot run anything.
Why this may not be a bug
CLAUDE.md's scope boundary is explicit that running a Lambda's code is out of scope:
Out of scope: actually running the work — executing user-data or cloud-init, running a Lambda's
code, performing an inference, running a training job, bootstrapping a node.
On that reading the Docker ZIP execution path is a capability that predates the boundary and that
the boundary now disclaims, and the honest resolution is to say so — in docs/services.md, which
today says nothing about Docker execution at all (no mention of the runtime interface emulator, and
no Lambda-execution section), and in LambdaExecCfg's own documentation.
The alternative reading is that the path is half-built rather than deliberately inert: it starts a
real container, waits for it to become ready, pools it, and returns whatever the runtime answers,
which is a lot of machinery for something meant not to work. Extracting the archive is a handful of
lines. But it would put substrate on the far side of a boundary CLAUDE.md draws deliberately, and
the reproducibility argument in doc.go is the reason that boundary exists — a caller's own code is
exactly the nondeterministic part.
This issue is the decision, not the extraction. Whichever way it goes, the current state is the
one thing that is not defensible: a documented feature that silently cannot do what its name says.
What this blocks
- Lambda: a warm container is never invalidated, so UpdateFunctionCode then Invoke runs the previous code #1035's fourth acceptance criterion, which is why that issue shipped without it. The warm-pool
invalidation is asserted through the pool's bookkeeping instead, which is observable without
Docker; there is no observable difference between the old code and the new one to assert on. - Any future test of Lambda execution semantics — timeouts, function errors from real handler
exceptions,Environmentreaching the handler — all of which would need a container that runs.
Acceptance criteria
- Decide whether the Docker ZIP execution path is meant to run a caller's handler, against
CLAUDE.md's scope boundary anddoc.go's reproducibility argument, and record the decision. - If it is not:
docs/services.mdgains a Lambda section stating what Docker execution does and
does not do,LambdaExecCfgandLambdaExecutor's doc comments say the same, and the ZIP
write either goes away or is documented as the record of intent it is (CLAUDE.md's "capture
such inputs as recorded intent" rule). - If it is: the archive is extracted into the mounted directory, with a test — Docker-gated —
that an invoke returns a value the handler computed, and Lambda: a warm container is never invalidated, so UpdateFunctionCode then Invoke runs the previous code #1035's fourth criterion becomes
reachable. - Either way, the stub path stays the default, since Docker execution is off unless configured.
Activity
scttfrdmn commentedon Sep 19, 2026
Verified before opening the PR. The decision is option 1: the Docker ZIP path is documented as inert, and the archive is not extracted. Four corrections to the body, one of which changes what the fix has to say.
The consequence is worse than "a function error", and this is the finding that decides the wording. The body says every invoke down this path "is a function error rather than the caller's result", which is right but understates it.
Execute(lambda_exec.go:87-104) degrades to the stub payload only when Docker is unavailable orgetOrStartContainerfails. Here neither happens:docker runsucceeds,waitReadysucceeds, the container is pooled, andinvokePOSTreturns whatever the RIE answered. The RIE answers 200 with an import-error body andX-Amz-Function-Error: Unhandled, andinvokeResponse(lambda_plugin.go:710) forwards that header verbatim. So a caller with Docker enabled does not get a stub and does not get an error from substrate — it gets a successfully-delivered report that its own handler raised, for code that was never loaded. That is indistinguishable from a realRuntime.ImportModuleError, which is precisely the failure mode a test of #393's header behaviour would be asserting on. Documenting the path as inert therefore has to name the observable, not just say "it does not run your code".archive/zipis already imported —cfn_deployer.go:4, used to build the inline-ZipFilepackage. So the body's "noarchive/zipreader exists outsidelambda_code_size_test.go" is wrong, and the absence of the import is not evidence either way about intent.docs/services.mddoes discuss Docker execution, contrary to "today says nothing about Docker execution at all".## Lambda(:5410) carries### Which operations drop a warm container(:5534), which opens "This applies only when Docker execution is configured. Without it there is no executor and no pool, which is the default and every CI run." and then tables the three evicting operations against what a container is started from. So the deliverable is a subsection beside that one, not a section from nothing — and the existing text is the right neighbour, because it is already about the container's relationship to the stored package.The final acceptance criterion already holds, and
LambdaExecCfgis not where it holds.LambdaExecCfg(:20-26) has exactly two fields,ReplayModeandWarmPoolTTL— there is noDockerEnabledon it. The gate iscfg.Lambda.DockerEnabledatplugins.go:121, which leaveslambdaExecnil unless configured, andconfig.go:754defaults it false. So "the stub path stays the default" is already true and needs no change; what misleads isLambdaExecutor's own doc comment at:36-37, which says the executor "falls back to stub responses when Docker is unavailable orDockerEnabledis false" — naming a field of a type that does not have it, and describing a fallback the type cannot make since it never sees the flag.Line citations have drifted:
startZIPContaineris:134-190(not:139-190), the ZIP write is:147, andstartImageContaineris:193(not:192).Adjacent defect, filing separately rather than folding in:
waitReady(:229-241) probes readiness by POSTing{}to the RIE's invocation endpoint and treats any HTTP answer as ready — so starting a container invokes the handler once with an empty payload before the caller's own invoke. On the ZIP path that is harmless because nothing runs; on the Image path, which does run real code, it is a spurious invocation whose side effects a caller never asked for.Scope reasoning for option 1, recorded here as the criterion asks: extraction is the completion of in-process workload execution, which
CLAUDE.mdplaces out of scope by name ("running a Lambda's code"), and it imports container-start latency, the handler's own I/O and clock, and an image pull over the network — which## Testingforbids a test to depend on. So the extraction could not be covered by any test in this repo, and the capability it completes is the onedoc.go's reproducibility argument exists to exclude. Option 1 changes no observable behaviour, keeps the ZIP write as the recorded intentCLAUDE.mdasks for, and replaces a silent wrong answer with a documented one.