Skip to content

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

Closed
@MCR2019

Description

@MCR2019

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions