fix: extension registration uses original AWS_LAMBDA_RUNTIME_API#737
Merged
Conversation
apply_runtime_proxy_config() overwrites AWS_LAMBDA_RUNTIME_API with the proxy address before the Adapter is created. register_extension_internal() then read the overwritten value, so extension register/next calls were sent through the proxy instead of the real Lambda Runtime API. Capture the original value in a process-wide OnceLock before the overwrite and prefer it in register_extension_internal(). No public API change.
seshubaws
reviewed
May 27, 2026
When apply_runtime_proxy_config() runs with AWS_LAMBDA_RUNTIME_API unset, ORIGINAL_LAMBDA_RUNTIME_API holds Some(None). The previous fallback chain collapsed Some(None) and None together, so the code fell through to env::var() — which by that point had been overwritten to the proxy address, defeating the fix. Use a match to keep the two cases distinct: when capture happened, never read the (now-overwritten) env var.
seshubaws
approved these changes
May 27, 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
Adapter::apply_runtime_proxy_config()overwritesAWS_LAMBDA_RUNTIME_APIwith the proxy address before the adapter is constructed.register_extension_internal()then read the (overwritten) env var, so extensionregisterandevent/nextcalls were routed through the proxy instead of the real Lambda Runtime API.AWS_LAMBDA_RUNTIME_APIvalue in a process-wideOnceLock<Option<String>>before the overwrite, and prefer it inregister_extension_internal(). Falls back to the env var (and then127.0.0.1:9001) when no original was captured.Test plan
cargo build --libcargo test --lib— 21/21 passtest_apply_runtime_proxy_configextended to assert the captured original value (folded into one test because theOnceLockis process-wide and only settable once)