Skip to content

docs(#1079): the Docker ZIP path is inert by decision, and what it answers is named - #1130

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/1079-lambda-zip-path-inert
Sep 19, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/1079-lambda-zip-path-inert

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #1079.

The issue asked for a decision, not an implementation. The decision is option 1: the Docker ZIP execution path does not extract the archive, and that is now documented rather than surprising. No observable behaviour changes — this is a doc-comment and service-reference PR.

What the path does

startZIPContainer (lambda_exec.go:134) writes the stored deployment package into a temp directory as a single file named function.zip and mounts that directory at /var/task:ro. The Lambda runtime interface expects /var/task to hold the module tree, so the container sees one archive and no index.py. No handler can be imported whatever the ZIP contains.

The observable is worse than a stub, and that is why this needed more than one sentence

The issue says every invoke down this path "is a function error rather than the caller's result". True, but it understates it in the direction that matters. Execute degrades to the stub payload only when the docker binary cannot be run or getOrStartContainer fails — and neither happens here. docker run succeeds, waitReady succeeds, the container is pooled, and invokePOST returns the runtime interface's own answer:

HTTP 200, an import-error body, and X-Amz-Function-Error: Unhandled — which invokeResponse (lambda_plugin.go:710) forwards verbatim, because forwarding it is #393's whole point.

So Invoke does not fail and does not stub. It reports, successfully, that the caller's handler raised — for code that was never loaded, indistinguishable from a genuine Runtime.ImportModuleError. That is the sentence the documentation has to contain; "it does not run your code" would leave a reader expecting a stub.

Why not extract

Extraction is a handful of lines, which is exactly why the issue framed itself as a decision. It is the completion of in-process execution of a caller's own code, which CLAUDE.md excludes by name ("Out of scope: actually running the work — … running a Lambda's code"), and doc.go's reproducibility argument is why that boundary is drawn: a caller's handler is the nondeterministic part. And no test here could cover it — an extracted-and-running container depends on container-start latency, the handler's own I/O and clock, and an image pull over the network, all three of which ## Testing forbids a test to depend on. So the capability would ship permanently unasserted, on the far side of the boundary, to make one already-documented failure mode into a different one.

The ZIP write stays, as the recorded intent the same boundary asks for. Those bytes are not decoration: they are what CodeSha256 and CodeSize are computed from, and what an UpdateFunctionCode replaces.

What a consumer actually needs from this surface — X-Amz-Function-Error, a Handled vs Unhandled distinction, a function-error payload — is already seedable through POST/DELETE /v1/lambda/invoke-error, which answers instantly and reproducibly where a real handler would not. That is the mechanism substrate offers in place of running the work, and the new docs subsection says so.

Corrections to the issue

  • archive/zip is already imported (cfn_deployer.go:4), used to build the inline-ZipFile package. So its absence is not evidence about intent, and the issue's "no archive/zip reader exists outside lambda_code_size_test.go" is wrong.
  • docs/services.md does discuss Docker execution. ### Which operations drop a warm container already opens by saying it applies only when Docker execution is configured, and tables the three evicting operations against what a container is started from. The new text is a subsection beside it, not a section from nothing — and that was the right neighbour, because it is already about the container's relationship to the stored package.
  • The last acceptance criterion already held, and LambdaExecCfg is not where it held. LambdaExecCfg has exactly two fields and neither is DockerEnabled; the gate is Config.Lambda.DockerEnabled, read once by RegisterDefaultPlugins, defaulting false. LambdaExecutor's doc comment named that nonexistent field — it claimed the executor falls back to the stub "when Docker is unavailable or DockerEnabled is false", a fallback it cannot make, since an executor exists only because the flag was set. Fixed, with the narrower fallback it does make stated instead.
  • Line citations drifted: startZIPContainer is :134-190 (not :139-190), the ZIP write is :147, startImageContainer is :193.

Adjacent defect, filed rather than folded in

waitReady probes readiness by POSTing {} to the runtime interface's invocation endpoint and treats any HTTP answer as ready. So starting a container invokes the handler once, with an event the caller never sent, ordered before its own. Harmless on the ZIP path — nothing runs — but on the image path, which does run real code, it is an unrequested invocation that recurs on every cold start. Filed as #1129 with a TCP-dial recommendation, and marked with a TODO(#1129) at the site.

What changed

  • LambdaExecCfg, LambdaExecutor, startZIPContainer, startImageContainer and waitReady doc comments.
  • One comment at the ZIP write naming it as recorded intent.
  • docs/services.md: a new ### Docker execution runs an image, never a ZIP subsection under ## Lambda, with the two-path table and the observable named.
  • CHANGELOG.md under ### Changed and ### Fixed.

No .go statement changed, so coverage is unmoved.

…swers is named

startZIPContainer mounts the deployment package without extracting it, so no
handler can be imported from /var/task whatever the ZIP contains. The decision
#1079 asked for is recorded as option 1: the archive stays unextracted, because
extracting it would complete in-process execution of a caller's own code — which
the scope boundary excludes by name and which no test here could cover without
depending on container-start latency, the handler's I/O and clock, and a network
image pull.

The observable is not a stub, which is the part the documentation has to name:
docker run succeeds, the readiness check succeeds, and invokePOST returns the
runtime interface's own 200 with an import-error body and
X-Amz-Function-Error: Unhandled. So Invoke reports that the caller's handler
raised, for code that was never loaded.

Also fixes LambdaExecutor's doc comment, which named a DockerEnabled field on
LambdaExecCfg that has never existed; the gate is Config.Lambda.DockerEnabled,
which is why #1079's stub-stays-the-default criterion already held.

Closes #1079.
@codecov

codecov Bot commented Sep 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 0fa1b56 into main Sep 19, 2026
17 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1079-lambda-zip-path-inert branch September 19, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lambda: the Docker ZIP execution path mounts the archive without extracting it, so no container can run a caller's handler

1 participant