Skip to content

Bug: APIGatewayRequestAuthorizerEventV2Schema has invalid definition for the identitySource field #3483

Closed
@hibanka

Description

@hibanka

Expected Behavior

The identitySource field in APIGatewayRequestAuthorizerEventV2 can be null when the Lambda authorizer is not configured with an identity source (see screenshot from the AWS Console below).

Image

Current Behavior

The current definition does not account for this scenario, leading to an error:

identitySource: APIGatewayStringArray,

Image

Even the @types/aws-lambda package has invalid type definition:

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/01bf6ea3ae73629f4d488d777df91781e466ba15/types/aws-lambda/trigger/api-gateway-authorizer.d.ts#L38

Code snippet

APIGatewayRequestAuthorizerEventV2Schema.parse(event);

Steps to Reproduce

When creating a Lambda authorizer, do not specify an identity source.

Possible Solution

add .nullable()

Powertools for AWS Lambda (TypeScript) version

latest

AWS Lambda function runtime

20.x

Packaging format used

npm

Execution logs

Activity

added
bugSomething isn't working
triageThis item has not been triaged by a maintainer, please wait
on Jan 16, 2025
am29d

am29d commented on Jan 17, 2025

@am29d
Contributor

Hey @hibanka , thanks for opening the issue, this makes sense, the docs even says the identity source is optional:

You can optionally specify identity sources for a Lambda authorizer.

Quick fix incoming...

Дякую!

added
parserThis item relates to the Parser Utility
and removed
triageThis item has not been triaged by a maintainer, please wait
on Jan 17, 2025
moved this from Triage to Working on it in Powertools for AWS Lambda (TypeScript)on Jan 17, 2025
self-assigned this
on Jan 17, 2025
added
confirmedThe scope is clear, ready for implementation
on Jan 17, 2025
leandrodamascena

leandrodamascena commented on Jan 17, 2025

@leandrodamascena
Contributor
am29d

am29d commented on Jan 17, 2025

@am29d
Contributor

I just ran a quick test in the console, I can't reproduce an event with identitySource: null on API GW V2. @hibanka how did you configure the API GW?

Here is an example event I have got:

{
    "level": "INFO",
    "sampling_rate": 0,
    "service": "service_undefined",
    "timestamp": "2025-01-17T09:53:25.550Z",
    "xray_trace_id": "1-678a2895-213d6967651dc359012d63e3",
    "version": "2.0",
    "type": "REQUEST",
    "routeArn": "arn:aws:execute-api:eu-west-1:xxx:xxx/dev/GET/",
    "routeKey": "GET /",
    "rawPath": "/dev/",
    "headers": {
        "accept": "*/*",
        "accept-encoding": "gzip, deflate",
        "content-length": "0",
        "host": "xxx.execute-api.eu-west-1.amazonaws.com",
        "user-agent": "HTTPie/3.2.3",
        "x-amzn-trace-id": "Root=1-678a2895-2366ebd0602dd62318fec21f",
        "x-forwarded-for": "188.192.53.6",
        "x-forwarded-port": "443",
        "x-forwarded-proto": "https"
    },
    "requestContext": {
        "accountId": "xxxx",
        "apiId": "8x9ewplh90",
        "domainName": "xxx.execute-api.eu-west-1.amazonaws.com",
        "domainPrefix": "xxx",
        "http": {
            "method": "GET",
            "path": "/dev/",
            "protocol": "HTTP/1.1",
            "sourceIp": "188.192.53.6",
            "userAgent": "HTTPie/3.2.3"
        },
        "requestId": "EhtHagMOjoEEMLA=",
        "routeKey": "GET /",
        "stage": "dev",
        "time": "17/Jan/2025:09:53:25 +0000",
        "timeEpoch": 1737107605402
    }
}

I called the endpoint from my terminal via public URL.

Edit: nvm, we remove null values with the logger.

github-actions

github-actions commented on Jan 17, 2025

@github-actions
Contributor

⚠️ COMMENT VISIBILITY WARNING ⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

added
pending-releaseThis item has been merged and will be released soon
and removed
confirmedThe scope is clear, ready for implementation
on Jan 17, 2025
github-actions

github-actions commented on Jan 28, 2025

@github-actions
Contributor

This is now released under v2.13.1 version!

added
completedThis item is complete and has been merged/shipped
and removed
pending-releaseThis item has been merged and will be released soon
on Jan 28, 2025
moved this from Coming soon to Shipped in Powertools for AWS Lambda (TypeScript)on Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcompletedThis item is complete and has been merged/shippedparserThis item relates to the Parser Utility

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

    Participants

    @am29d@leandrodamascena@hibanka

    Issue actions

      Bug: `APIGatewayRequestAuthorizerEventV2Schema` has invalid definition for the `identitySource` field · Issue #3483 · aws-powertools/powertools-lambda-typescript