feat: Add Lambda-Runtime-Invocation-Id support for cross-wiring protection - #214
Merged
Conversation
vip-amzn
force-pushed
the
feat/invocation-id-cross-wiring
branch
3 times, most recently
from
July 17, 2026 12:56
39f026b to
b132afb
Compare
vip-amzn
force-pushed
the
feat/invocation-id-cross-wiring
branch
3 times, most recently
from
July 27, 2026 09:02
09c0624 to
c14cbf5
Compare
vip-amzn
force-pushed
the
feat/invocation-id-cross-wiring
branch
from
July 28, 2026 10:18
c14cbf5 to
1fea904
Compare
…ction Echo the invocation ID received from RAPID on /next back on /response and /error, enabling RAPID to detect and reject stale responses from timed-out invocations. Fully backward compatible — header only sent when received.
vip-amzn
force-pushed
the
feat/invocation-id-cross-wiring
branch
from
July 28, 2026 10:23
1fea904 to
a5775f7
Compare
darklight3it
approved these changes
Jul 28, 2026
maxday
reviewed
Jul 29, 2026
| self.assertEqual(event_request.tenant_id, "") | ||
| self.assertEqual(event_request.event_body, response_body) | ||
|
|
||
| @patch("awslambdaric.lambda_runtime_client.runtime_client") |
Member
There was a problem hiding this comment.
All new tests all patch awslambdaric.lambda_runtime_client.runtime_client, so they verify Python-level argument threading, real value, but they stop one layer above the feature. The actual behavior lives in the C++ patch:
if (!invocation_id.empty()) {
headers = curl_slist_append(headers, (std::string(INVOCATION_ID_HEADER) + ": " + invocation_id).c_str());
}If someone re-rolls the tarball and drops aws-lambda-cpp-add-invocation-id.patch from update_deps.sh, all tests still pass and the feature silently disappears.
Can you add the following tests?
- Round trip:
/nextreturnsLambda-Runtime-Invocation-Id: abc123→ the subsequent/responserequest carriesLambda-Runtime-Invocation-Id: abc123. - Omission:
/nextsends no such header →/responsecarries no such header (not an empty one). This is the backward-compat claim. - Error path: same round trip via
/error, sincepost_failureis a separate C++ overload.
The existing tests all patch runtime_client, so they verify Python-level argument threading but stop one layer above the behaviour. The header is emitted by libcurl inside the compiled extension. If aws-lambda-cpp-add-invocation-id.patch is dropped when the vendored tarball is re-rolled, every test still passes and the feature silently disappears. Add tests that drive the built extension against a stub RAPID on a real socket, asserting on raw received headers: round trip via /response, the /error path, and omission (no header at all, rather than an empty one). Verified by removing the curl_slist_append call and rebuilding — the new tests fail while the existing suite stays green. The client half runs as a subprocess because post_invocation_result and post_error hold the GIL across the blocking curl call, so an in-process stub server thread would never be scheduled to answer the POST.
test: assert the invocation ID reaches the wire
maxday
self-requested a review
July 29, 2026 17:07
maxday
approved these changes
Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
Lambda-Runtime-Invocation-Idheader support for cross-wiring protection.The RIC now echoes the invocation ID received from RAPID on
/nextback on/responseand/error, enabling RAPID to detect and reject stale responses from timed-out invocations.Problem
On Lambda Managed Instances (LMI) and On-Demand (OD), when an invoke times out, the runtime process continues running in the background. If a new invoke arrives with the same
requestId, RAPID accepts it. The still-running old invocation eventually posts its response, and RAPID matches it to the new invoke — delivering the wrong response (cross-wiring).Solution
RAPID sends a unique per-invoke nonce via
Lambda-Runtime-Invocation-Idheader on/next. The runtime echoes it back on/responseand/error. RAPID validates the match before accepting the response.Changes
runtime_client.cpp: ParseLambda-Runtime-Invocation-Idfrom/nextresponse, pass topost_success/post_failureviazformat (acceptsNone→nullptr)lambda_runtime_client.py: Threadinvocation_idthrough to native clientbootstrap.py: Passinvocation_idfrom event request to response/error postingdeps/patches/aws-lambda-cpp-add-invocation-id.patch: Patchaws-lambda-cppto supportinvocation_idinget_next/do_postdeps/patches/aws-lambda-cpp-musl-no-execinfo.patch: Extracted Alpine/musl fix from d3e9632 into a proper patch file soupdate_deps.shcan reproduce the tarball from scratch (previously baked directly into the tarball without a patch — see d3e9632)Backward Compatibility
Fully backward compatible in both directions:
Testing