Skip to content

fix: extension registration uses original AWS_LAMBDA_RUNTIME_API#737

Merged
bnusunny merged 2 commits into
mainfrom
fix/extension-register-uses-original-runtime-api
May 28, 2026
Merged

fix: extension registration uses original AWS_LAMBDA_RUNTIME_API#737
bnusunny merged 2 commits into
mainfrom
fix/extension-register-uses-original-runtime-api

Conversation

@bnusunny
Copy link
Copy Markdown
Contributor

Summary

  • Adapter::apply_runtime_proxy_config() overwrites AWS_LAMBDA_RUNTIME_API with the proxy address before the adapter is constructed. register_extension_internal() then read the (overwritten) env var, so extension register and event/next calls were routed through the proxy instead of the real Lambda Runtime API.
  • Capture the original AWS_LAMBDA_RUNTIME_API value in a process-wide OnceLock<Option<String>> before the overwrite, and prefer it in register_extension_internal(). Falls back to the env var (and then 127.0.0.1:9001) when no original was captured.
  • No public API change.

Test plan

  • cargo build --lib
  • cargo test --lib — 21/21 pass
  • Existing test_apply_runtime_proxy_config extended to assert the captured original value (folded into one test because the OnceLock is process-wide and only settable once)

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.
Comment thread src/lib.rs Outdated
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.
@bnusunny bnusunny merged commit a0f1f3c into main May 28, 2026
7 checks passed
@bnusunny bnusunny deleted the fix/extension-register-uses-original-runtime-api branch May 28, 2026 01:13
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.

2 participants