Skip to content
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

fix(aws-lambda): Fix query string handling for v1 #3717

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/adapter/aws-lambda/handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ describe('EventProcessor.createRequest', () => {
header1: ['value1'],
header2: ['value1', 'value2', 'value3'],
},
// This value doesn't match multi value's content.
// We want to assert handler is using the multi value's content when both are available.
queryStringParameters: {
parameter2: 'value',
},
Expand Down Expand Up @@ -96,7 +98,7 @@ describe('EventProcessor.createRequest', () => {

expect(request.method).toEqual('GET')
expect(request.url).toEqual(
'https://id.execute-api.us-east-1.amazonaws.com/my/path?parameter2=value'
'https://id.execute-api.us-east-1.amazonaws.com/my/path?parameter1=value1&parameter1=value2&parameter2=value'
)
expect(Object.fromEntries(request.headers)).toEqual({
'content-type': 'application/json',
Expand Down
16 changes: 12 additions & 4 deletions src/adapter/aws-lambda/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,17 +325,25 @@
}

protected getQueryString(event: Exclude<LambdaEvent, APIGatewayProxyEventV2>): string {
return Object.entries(event.queryStringParameters || {})
.filter(([, value]) => value)
.map(([key, value]) => `${key}=${value}`)
.join('&')
// In the case of gateway Integration either queryStringParameters or multiValueQueryStringParameters can be present not both
if (event.multiValueQueryStringParameters) {
return Object.entries(event.multiValueQueryStringParameters || {})
.filter(([, value]) => value)
.map(([key, value]) => `${key}=${value.join(`&${key}=`)}`)
.join('&')
} else {
return Object.entries(event.queryStringParameters || {})
.filter(([, value]) => value)
.map(([key, value]) => `${key}=${value}`)
.join('&')
}
}

protected getCookies(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
event: Exclude<LambdaEvent, APIGatewayProxyEventV2>,

Check failure on line 344 in src/adapter/aws-lambda/handler.ts

View workflow job for this annotation

GitHub Actions / Main

'event' is declared but its value is never read.

Check failure on line 344 in src/adapter/aws-lambda/handler.ts

View workflow job for this annotation

GitHub Actions / Node.js v18.18.2

'event' is declared but its value is never read.

Check failure on line 344 in src/adapter/aws-lambda/handler.ts

View workflow job for this annotation

GitHub Actions / Node.js v20.x

'event' is declared but its value is never read.

Check failure on line 344 in src/adapter/aws-lambda/handler.ts

View workflow job for this annotation

GitHub Actions / workerd

'event' is declared but its value is never read.

Check failure on line 344 in src/adapter/aws-lambda/handler.ts

View workflow job for this annotation

GitHub Actions / Node.js v22.x

'event' is declared but its value is never read.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
headers: Headers

Check failure on line 346 in src/adapter/aws-lambda/handler.ts

View workflow job for this annotation

GitHub Actions / Main

'headers' is declared but its value is never read.

Check failure on line 346 in src/adapter/aws-lambda/handler.ts

View workflow job for this annotation

GitHub Actions / Node.js v18.18.2

'headers' is declared but its value is never read.

Check failure on line 346 in src/adapter/aws-lambda/handler.ts

View workflow job for this annotation

GitHub Actions / Node.js v20.x

'headers' is declared but its value is never read.

Check failure on line 346 in src/adapter/aws-lambda/handler.ts

View workflow job for this annotation

GitHub Actions / workerd

'headers' is declared but its value is never read.

Check failure on line 346 in src/adapter/aws-lambda/handler.ts

View workflow job for this annotation

GitHub Actions / Node.js v22.x

'headers' is declared but its value is never read.
): void {
// nop
}
Expand Down
Loading