Skip to content

chore(parser): deprecate AlbMultiValueHeadersSchema #3523

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

Merged
merged 1 commit into from
Jan 24, 2025
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
51 changes: 35 additions & 16 deletions packages/parser/src/schemas/alb.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { z } from 'zod';

/**
* Zod schema for Application load balancer event
* Zod schema for Application Load Balancer events.
*
* @example
* ```json
Expand Down Expand Up @@ -33,6 +33,32 @@ import { z } from 'zod';
* }
* ```
*
* With multi-value headers and multi-value query string parameters:
*
* @example
* ```json
* {
* "requestContext": {
* "elb": {
* "targetGroupArn": "arn:aws:elasticloadbalancing:region:123456789012:targetgroup/my-target-group/6d0ecf831eec9f09"
* }
* },
* "httpMethod": "GET",
* "path": "/",
* "multiValueHeaders": {
* "Set-cookie": [
* "cookie-name=cookie-value;Domain=myweb.com;Secure;HttpOnly",
* "cookie-name=cookie-value;Expires=May 8, 2019"
* ],
* "Content-Type": [
* "application/json"
* ]
* },
* "isBase64Encoded": false,
* "body": "request_body"
* }
* ```
*
* @see {@link types.ALBEvent | ALBEvent}
* @see {@link https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html}
* @see {@link https://docs.aws.amazon.com/lambda/latest/dg/services-alb.html}
Expand All @@ -43,7 +69,11 @@ const AlbSchema = z.object({
body: z.string(),
isBase64Encoded: z.boolean(),
headers: z.record(z.string(), z.string()).optional(),
multiValueHeaders: z.record(z.string(), z.array(z.string())).optional(),
queryStringParameters: z.record(z.string(), z.string()).optional(),
multiValueQueryStringParameters: z
.record(z.string(), z.array(z.string()))
.optional(),
requestContext: z.object({
elb: z.object({
targetGroupArn: z.string(),
Expand All @@ -52,26 +82,15 @@ const AlbSchema = z.object({
});

/**
* Zod schema for Application load balancer event with multi-value headers
* @deprecated Use `AlbSchema` instead, which handles both types of headers & querystring parameters.
*
* @example
* ```json
* {
* "multiValueHeaders": {
* "Set-cookie": [
* "cookie-name=cookie-value;Domain=myweb.com;Secure;HttpOnly",
* "cookie-name=cookie-value;Expires=May 8, 2019"
* ],
* "Content-Type": [
* "application/json"
* ]
* }
* }
* ```
* This schema will be removed in a future major release.
*/
/* v8 ignore start */
const AlbMultiValueHeadersSchema = AlbSchema.extend({
multiValueHeaders: z.record(z.string(), z.array(z.string())),
multiValueQueryStringParameters: z.record(z.string(), z.array(z.string())),
});
/* v8 ignore stop */

export { AlbSchema, AlbMultiValueHeadersSchema };
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
},
"body": "Test",
"isBase64Encoded": false
}
}
35 changes: 35 additions & 0 deletions packages/parser/tests/events/alb/multi-fields.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"requestContext": {
"elb": {
"targetGroupArn": "arn:aws:elasticloadbalancing:us-east-2:123456789012:targetgroup/lambda-279XGJDqGZ5rsrHC2Fjr/49e9d65c45c6791a"
}
},
"httpMethod": "GET",
"path": "/lambda",
"multiValueQueryStringParameters": {},
"multiValueHeaders": {
"accept": [
"*/*"
],
"host": [
"alb-c-LoadB-14POFKYCLBNSF-1815800096.eu-central-1.elb.amazonaws.com"
],
"user-agent": [
"curl/7.79.1"
],
"x-amzn-trace-id": [
"Root=1-62fa9327-21cdd4da4c6db451490a5fb7"
],
"x-forwarded-for": [
"123.123.123.123"
],
"x-forwarded-port": [
"80"
],
"x-forwarded-proto": [
"http"
]
},
"body": "Test",
"isBase64Encoded": false
}
28 changes: 0 additions & 28 deletions packages/parser/tests/events/albEventPathTrailingSlash.json

This file was deleted.

23 changes: 0 additions & 23 deletions packages/parser/tests/events/albMultiValueHeadersEvent.json

This file was deleted.

Loading
Loading