Skip to content

fix(lambda): return X-Amz-Log-Result for buffered Invoke with LogType=Tail#1931

Merged
vieiralucas merged 2 commits into
mainfrom
fix/lambda-invoke-logresult
Jun 25, 2026
Merged

fix(lambda): return X-Amz-Log-Result for buffered Invoke with LogType=Tail#1931
vieiralucas merged 2 commits into
mainfrom
fix/lambda-invoke-logresult

Conversation

@vieiralucas

@vieiralucas vieiralucas commented Jun 24, 2026

Copy link
Copy Markdown
Member

Summary (1.20)

A synchronous Invoke with LogType=Tail must return the base64 of the last 4 KiB of the invocation's logs in X-Amz-Log-Result (the SDK's LogResult). The buffered RequestResponse path never set it — only the streaming eventstream path carried the field, and even there it was always empty. So aws lambda invoke --log-type Tail and test harnesses got nothing.

Adds a per-instance log-capture hook to the runtime backend trait (instance_logs): the docker/podman backend tails docker logs, the k8s backend fetches the Pod's logs via the kube API. invoke_inner optionally captures the instance's log tail while the slot is still held; the buffered handler, when LogType=Tail, base64s the last 4 KiB into X-Amz-Log-Result. The other ~22 invoke callers are unchanged (they go through the no-capture wrapper).

Non-code surface

No new API surface — fills in a documented response header. No SDK/docs/metadata change applies (checked).

Test plan

  • E2E (Docker-gated) invoke_with_log_type_tail_returns_log_result: a function prints a marker; Invoke with LogType=Tail returns a LogResult decoding to contain it.
  • cargo test -p fakecloud-lambda --lib (207) passes; clippy clean.

Summary by cubic

Fixes buffered Lambda Invoke so X-Amz-Log-Result is returned for LogType=Tail, base64-encoding the last 4 KiB of the function logs. Works for both Docker and Kubernetes backends via per-instance log capture.

  • Bug Fixes
    • Return X-Amz-Log-Result for synchronous Invoke with LogType=Tail (last 4 KiB, base64).
    • Add instance_logs backend hook; Docker tails docker logs, K8s reads Pod logs via the kube API.
    • Add E2E test verifying the log tail and register it in the Python runtime partition filter.

Written for commit b2e9b6c. Summary will update on new commits.

Review in cubic

…=Tail

A synchronous Invoke with LogType=Tail must return the base64 of the last 4 KiB
of the invocation's logs in X-Amz-Log-Result (the SDK's LogResult). The buffered
RequestResponse path never set it — only the streaming eventstream path carried
the field, and even there it was always empty. So test harnesses and the AWS
CLI's --log-type Tail got nothing.

Adds a per-instance log-capture hook to the runtime backend trait
(instance_logs): the docker/podman backend tails `docker logs`, the k8s backend
fetches the Pod's logs via the kube API. invoke_inner optionally captures the
instance's log tail while the slot is still held; the buffered handler, when
LogType=Tail, base64s the last 4 KiB into X-Amz-Log-Result.

E2E (Docker-gated): a function prints a marker to stdout; invoking with
LogType=Tail returns a LogResult that decodes to contain it.
The new invoke_with_log_type_tail_returns_log_result test runs a python3.12
function, so the e2e partition coverage check requires it to be enumerated in
a lambda_invoke partition. Add it to the python runtime-family filter
(matching test_invoke_warm_start and the other non-runtime python tests).
@vieiralucas vieiralucas merged commit c2b9148 into main Jun 25, 2026
94 checks passed
@vieiralucas vieiralucas deleted the fix/lambda-invoke-logresult branch June 25, 2026 03:31
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.

1 participant