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

Bug: APIGatewayRestResolver - openAPI metadata responses / tags on @router fails with unhashable type: dict #3506

Closed
MCR2019 opened this issue Dec 14, 2023 · 7 comments · Fixed by #3514
Assignees
Labels
bug Something isn't working event_handlers

Comments

@MCR2019
Copy link

MCR2019 commented Dec 14, 2023

Expected Behaviour

When adding responses or tags metadata to a router this should behave in the same was as when it is added to the app.

Current Behaviour

When the routers are added to the app the metadata is used as a key. As the metadata fields for responses and tags are Dict and List then this produces the following error:

File "/Users/my_path/venv/lib/python3.10/site-packages/aws_lambda_powertools/event_handler/api_gateway.py", line 2160, in register_route
    self._routes_with_middleware[route_key] = []
TypeError: unhashable type: 'dict'

Code snippet

from aws_lambda_powertools.event_handler import APIGatewayRestResolver
from aws_lambda_powertools.event_handler.api_gateway import Router

router = Router()

app = APIGatewayRestResolver(enable_validation=True)
app.include_router(router)


@router.put(
    "/example-resource",
    responses={200: {"description": "Todo item found"}},
    tags=["Examples"]
)
def put():
    """"""


if __name__ == "__main__":
    """"""

Possible Solution

No response

Steps to Reproduce

  • Create APIGatewatRestResolver.
  • Create api_gateway Router.
  • Add method to Router with responses or tags metadata.
  • Add Router to app.

Powertools for AWS Lambda (Python) version

2.29.1

AWS Lambda function runtime

3.10

Packaging format used

PyPi

Debugging logs

No response

@MCR2019 MCR2019 added bug Something isn't working triage Pending triage from maintainers labels Dec 14, 2023
Copy link

boring-cyborg bot commented Dec 14, 2023

Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

@leandrodamascena
Copy link
Contributor

Hello @MCR2019! Thanks for reporting this bug! I was able to reproduce the error and we are working to fix it.
As it appears critical for those who are using the Router object and now integrating with the new OpenAPI utility, we will fix it as soon as possible and plan to release a patch by tomorrow.

We apologize for this bug. OpenAPI + Swagger are new utilities and we try our best to create tests and keep our code coverage high. Unfortunately, some things go through and we can't simulate them until someone reports it 😞

Thank you.

@leandrodamascena leandrodamascena moved this from Triage to Working on it in Powertools for AWS Lambda (Python) Dec 14, 2023
@leandrodamascena leandrodamascena added event_handlers and removed bug Something isn't working labels Dec 14, 2023
@leandrodamascena leandrodamascena added bug Something isn't working and removed triage Pending triage from maintainers labels Dec 15, 2023
@rubenfonseca
Copy link
Contributor

Working at this now!

Copy link
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.

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

This is now released under 2.30.1 version!

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

@MCR2019 thank you again for reporting this, we've just released 2.30.1 that should fix the problem you found!

@rubenfonseca rubenfonseca moved this from Coming soon to Shipped in Powertools for AWS Lambda (Python) Dec 15, 2023
@MCR2019
Copy link
Author

MCR2019 commented Dec 18, 2023

@rubenfonseca - Thank you for fixing so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working event_handlers
Projects
Status: Shipped
3 participants