fix(event-handler): handle CORS preflight OPTIONS in HttpResolverLocal#8268
Conversation
…figured HttpResolverLocal overrode _resolve_async, _call_route_async, _run_middleware_chain_async, and _handle_not_found_async, duplicating the parent's logic without the CORS preflight branch. OPTIONS requests fell through to the not-found handler and, if a generic exception handler was registered, returned 500 with no CORS headers. Replace all four overrides with a single thin _resolve_async that delegates to super()._resolve_async() and serializes the returned ResponseBuilder to dict. The parent already handles route matching, CORS preflight (OPTIONS → 204), not-found, and exception handling correctly. Fixes aws-powertools#8267
|
Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8268 +/- ##
===========================================
- Coverage 96.72% 96.58% -0.14%
===========================================
Files 286 286
Lines 14347 14294 -53
Branches 1201 1192 -9
===========================================
- Hits 13877 13806 -71
- Misses 341 357 +16
- Partials 129 131 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
leandrodamascena
left a comment
There was a problem hiding this comment.
Amazing! APPROVED
|
|
Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience! |



Issue number: closes #8267
Summary
Changes
HttpResolverLocalwas overriding_resolve_async,_call_route_async,_run_middleware_chain_async, and_handle_not_found_async, duplicating the parent's logic but without the CORS preflight branch present inApiGatewayResolver._handle_not_found_async.OPTIONSrequests fell through to the not-found handler and, if a generic@app.exception_handler(Exception)was registered, returned 500 with no CORS headers — blocking browser preflight checks.Replaces all four overrides with a single thin
_resolve_asyncthat callssuper()._resolve_async()and serializes the returnedResponseBuildertodictfor the ASGI layer. The parent already handles route matching, CORS preflight (OPTIONS→ 204), not-found, and exception handling correctly.User experience
Before:
OPTIONSpreflight toHttpResolverLocalwithcors=CORSConfig(...)returns 500 with no CORS headers. Browser blocks the actual request.After:
OPTIONSpreflight returns 204 with correctAccess-Control-Allow-OriginandAccess-Control-Allow-Methodsheaders, matchingAPIGatewayRestResolverbehavior.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.