-
Notifications
You must be signed in to change notification settings - Fork 406
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
Security configuration for route does not work for APIGatewayHttpRouter #4375
Comments
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
Hey @mdwornicki! Thanks for reporting this bug! I was able to reproduce the error and I expect to send a PR tomorrow to fix the problem. |
Hi @mdwornicki! This has been a little harder than I expected. Made some progress, but still validating the solution. |
Hey @mdwornicki! I submitted a PR to fix this. |
@mdwornicki, we're releasing it next Thursday (13th) - do let us know otherwise whether you can't wait until then. |
Thank you! It's not a problem, can wait! |
great, thanks!! For anyone reading this later as it's useful context but not blocking this fix for next week's release... As part of the security scheme bug fix review (#4421), we found that the responsibilities between OpenAPI and SwaggerUI are ambiguous, leading to confusion among customers and maintainers at times. As of now, these are common use cases:
We're confusing customers on 1 and 2, because How do we fix it in a backwards compatible way and improve everyone's experience?
|
|
This is now released under 2.39.0 version! |
Expected Behaviour
Method
get_openapi_json_schema
fromAPIGatewayHttpResolver
should work for routes fromAPIGatewayHttpRouter
with thesecurity
parameter.Current Behaviour
When the
security
parameter is a part of the router (APIGatewayHttpRouter
), it doesn't work -/openapispec
has:{"message": "Internal Server Error"}
.If I remove the
security
parameter from the router file, it works, and it means that the security configuration is correct only forAPIGatewayHttpResolver
.Error in CloudWatch after
/openapispec
execution:[ERROR] TypeError: unhashable type: 'list' Traceback (most recent call last): File "/var/lang/lib/python3.12/importlib/__init__.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1387, in _gcd_import File "<frozen importlib._bootstrap>", line 1360, in _find_and_load File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 935, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 995, in exec_module File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed File "/var/task/app.py", line 14, in <module> from project_member_v1 import router as project_member_router File "/var/task/project_member_v1/router.py", line 27, in <module> @router.get( File "/opt/python/aws_lambda_powertools/event_handler/api_gateway.py", line 2412, in register_route self._routes_with_middleware[route_key] = []
Code snippet
Possible Solution
No response
Steps to Reproduce
APIGatewayHttpResolver
APIGatewayHttpRouter
OpenApiConfiguration
and define security_schemes@app.get("/openapispec", tags=["Docs"], summary="Get the OpenAPI specification") def get_openapi(): return app.get_openapi_json_schema(**OpenApiConfiguration.get_meta_data())
/openapispec
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.12
Packaging format used
Lambda Layers
Debugging logs
No response
The text was updated successfully, but these errors were encountered: