awslabs / aws-lambda-rust-runtime

A Rust runtime for AWS Lambda
Apache License 2.0
3.29k stars 335 forks source link

ApiGatewayV2CustomAuthorizerV2Request identity_source as optional #860

Closed HVKukkonen closed 4 months ago

HVKukkonen commented 4 months ago

Issue #, if available: None

Description of changes: Fixes typing issue with ApiGatewayV2CustomAuthorizerV2Request not allowing for None as the identity_source. I suspect this being an issue as per the docs

When caching is turned off, it is not necessary to specify an identity source. API Gateway directly passes the request to the authorizer Lambda function.

Also, I have run into issues with this in the wild as not having the identity source in the API Gateway Terraform configuration results in DeserializeError { inner: Error { path: Path { segments: [Map { key: \"identitySource\" }] }, original: Error(\"invalid type: null, expected a sequence\" in my Authorizer code. And after specifying an arbitrary field from the API Gateway event as the identity source it worked fine.

By submitting this pull request

bnusunny commented 4 months ago

Could you add a test to cover this case?

HVKukkonen commented 4 months ago

Added. Of course, nothing guarantees that the fixture used exactly matches the event from the API Gateway but that's the same issue with all of the fixtures, right? :smiling_face_with_tear:

bnusunny commented 4 months ago

Could you fix the linting errors?