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

APIGatewayProxyEventV2: Headers Property in BaseProxyEvent Returns Incorrect Type #30541

Closed
adriamontoto opened this issue Jun 13, 2024 · 3 comments
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@adriamontoto
Copy link

Describe the bug

In the AWS CDK, the BaseProxyEvent class, which is the parent class of APIGatewayProxyEventV2, contains a property headers that is supposed to return a dictionary. However, when using the APIGatewayProxyEventV2 class, the headers property returns a string instead of a dictionary, which is inconsistent with the documented behavior of BaseProxyEvent.

class BaseProxyEvent(DictWrapper):
    @property
    def headers(self) -> Dict[str, str]:
        return self.get("headers") or {}

Expected Behavior

The headers property of the BaseProxyEvent class (and its subclass APIGatewayProxyEventV2) should return a dictionary as per its property definition and documentation.

request = APIGatewayProxyEventV2(data=event)
print(type(request.headers))  # Expected: <class 'dict'>

Current Behavior

The headers property of the APIGatewayProxyEventV2 class returns a string instead of a dictionary.

request = APIGatewayProxyEventV2(data=event)
print(type(request.headers))  # Actual: <class 'str'>

Reproduction Steps

Create a lambda function (with the following code) that is triggered by a gateway endpoint (Proxy integration).

from aws_lambda_powertools.utilities.data_classes import APIGatewayProxyEventV2

def lambda_handler(event, context):
      request= APIGatewayProxyEventV2(data=event)
      print(type(request.headers)) 

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.128.0 (build d995261)

Framework Version

No response

Node.js Version

10.8.1

OS

Windows 11

Language

Python

Language Version

3.11.9

Other information

No response

@adriamontoto adriamontoto added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 13, 2024
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Jun 13, 2024
@adriamontoto adriamontoto closed this as not planned Won't fix, can't repro, duplicate, stale Jun 13, 2024
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues 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.

1 similar comment
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues 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.

@aws-cdk-automation
Copy link
Collaborator

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.

@aws aws locked as resolved and limited conversation to collaborators Jul 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants