-
Notifications
You must be signed in to change notification settings - Fork 736
fix(localstack/lambda): lambda debugging #8291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
skyrpex
wants to merge
8
commits into
aws:master
Choose a base branch
from
skyrpex:drg-191-lambda-debugging-with-aws-toolkit-fails
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix(localstack/lambda): lambda debugging #8291
skyrpex
wants to merge
8
commits into
aws:master
from
skyrpex:drg-191-lambda-debugging-with-aws-toolkit-fails
Conversation
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
…gging-with-aws-toolkit-fails
This prevents future mistakes by exposing a readonly array `customUserAgentBase` in non-readonly arrays in methods such as `getLambdaDebugUserAgentPairs()`
laileni-aws
added a commit
that referenced
this pull request
Nov 19, 2025
## Problem The AWS SDK v2 to v3 migration in PR #8183 introduced breaking changes for LocalStack compatibility and Lambda debugging is not working anymore: 1. **User Agent format changed:** The migration changed from string-based user agents to AWS SDK v3's `UserAgent` pairs format (`[name, version]` tuples), but several places still used the old string format, breaking LocalStack's custom user agent for Lambda debugging and part of the integration with IoT 2. **Response headers no longer accessible**: AWS SDK v3 removed access to HTTP response headers via `$response.httpResponse.headers`, breaking LocalStack connection detection which relies on the `x-localstack-request-url` header These issues were not caught most likely because LocalStack compatibility was not tested during the SDK v3 migration. ## Solution 1. Fix user agent format for AWS SDK v3 * Migrated from string-based user agents to proper UserAgent pairs format: * Changed from "LAMBDA-DEBUG/1.0.0 AWS-Toolkit/..." (string) * To [['LAMBDA-DEBUG', '1.0.0'], ['AWS-Toolkit', '2.0'], ...] (pairs) * Updated awsClientBuilderV3 to use customUserAgent instead of userAgent 2. Add response headers middleware for AWS SDK v3 * Added `captureHeadersMiddleware` to `AWSClientBuilderV3` that attaches HTTP response headers to the output via `$httpHeaders` property * Updated `loginManager` to check for LocalStack connection using `$httpHeaders` instead of the removed `$response.httpResponse.headers` ## AWS SDK v3 Breaking Changes ### User Agent Format **SDK v2**: ```ts // String format in client options const options = { region: 'us-east-1', userAgent: 'LAMBDA-DEBUG/1.0.0 AWS-Toolkit/2.0.0' } ``` **SDK v3:** ```ts // Array of [name, version] tuples const options = { region: 'us-east-1', customUserAgent: [ ['LAMBDA-DEBUG', '1.0.0'], ['AWS-Toolkit', '2.0.0'] ] } ``` ### Response Headers Access **SDK v2**: ```ts const response = await client.send(command) // Headers directly accessible const headers = response.$response.httpResponse.headers const localStackUrl = headers['x-localstack-request-url'] ``` **SDK v3**: ```ts const response = await client.send(command) // Headers NOT accessible by default - requires custom middleware const headers = response.$httpHeaders // undefined without middleware ``` Supersedes #8289 and #8291 --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Co-authored-by: carole-lavillonniere <[email protected]> Co-authored-by: Cristian Pallarés <[email protected]> Co-authored-by: Laxman Reddy <[email protected]>
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.
Problem
The AWS SDK v2 to v3 migration in PR #8183 introduced breaking changes for LocalStack compatibility and Lambda debugging is not working anymore:
UserAgentpairs format ([name, version]tuples), but several places still used the old string format, breaking LocalStack's custom user agent for Lambda debugging$response.httpResponse.headers, breaking LocalStack connection detection which relies on thex-localstack-request-urlheaderThese issues were not caught most likely because LocalStack compatibility was not tested during the SDK v3 migration.
Solution
Add response headers middleware for AWS SDK v3
captureHeadersMiddlewaretoAWSClientBuilderV3that attaches HTTP response headers to the output via$httpHeaderspropertyloginManagerto check for LocalStack connection using$httpHeadersinstead of the removed$response.httpResponse.headersFix user agent format for AWS SDK v3
AWS SDK v3 Breaking Changes
User Agent Format
SDK v2:
SDK v3:
Response Headers Access
SDK v2:
SDK v3:
Supersedes #8289 as @carole-lavillonniere is OOO today and can't edit their PR.