Skip to content

Bug: Remove get_lambda function from API Gateway proxy event #3453

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

Closed
leandrodamascena opened this issue Dec 5, 2023 · 3 comments · Fixed by #3454
Closed

Bug: Remove get_lambda function from API Gateway proxy event #3453

leandrodamascena opened this issue Dec 5, 2023 · 3 comments · Fixed by #3454
Assignees
Labels
event_sources Event Source Data Class utility not-a-bug

Comments

@leandrodamascena
Copy link
Contributor

Expected Behaviour

The API Gateway v2 payload doesn´t have any field called lambda and we should not have this in our Data Class.

Current Behaviour

Unecessary get_lambda function.

Code snippet

No code snippet

Possible Solution

Remove this and adjust tests/payload

@property
def get_lambda(self) -> Optional[Dict[str, Any]]:
    """Lambda authorization context details"""
    return self.get("lambda")

Steps to Reproduce

No necessary

Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.10

Packaging format used

PyPi

Debugging logs

No response

@heitorlessa
Copy link
Contributor

Adding update as it turned out docs were wrong, lambda key is always present; we only didn't do a good job in providing a consistent UX in getting Authorizer Context keys injected by Lambda Authorizers.


Potential solution discussed in today's sync:

from aws_lambda_powertools.utilities.data_classes.api_gateway_proxy_event import APIGatewayProxyEvent, APIGatewayProxyEventV2

a = APIGatewayProxyEvent({})
b = APIGatewayProxyEventV2({})

ctx: dict = a.request_context.authorizer.get_context()  # or get_lambda_context
ctx_two: dict = b.request_context.authorizer.get_context()  # or get_lambda_context

ctx.get("tenant_id")
ctx_two.get("tenant_id")

@github-project-automation github-project-automation bot moved this from Working on it to Coming soon in Powertools for AWS Lambda (Python) Dec 6, 2023
Copy link
Contributor

github-actions bot commented Dec 6, 2023

⚠️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.

@github-actions github-actions bot added the pending-release Fix or implementation already in dev waiting to be released label Dec 6, 2023
Copy link
Contributor

github-actions bot commented Dec 6, 2023

This is now released under 2.29.0 version!

@github-actions github-actions bot removed the pending-release Fix or implementation already in dev waiting to be released label Dec 6, 2023
@heitorlessa heitorlessa moved this from Coming soon to Shipped in Powertools for AWS Lambda (Python) Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
event_sources Event Source Data Class utility not-a-bug
Projects
Status: Shipped
2 participants