Skip to content

Conversation

@leandrodamascena
Copy link
Contributor

Issue number: closes #7912

Summary

Adds HttpResolverAlpha - a new resolver that implements ASGI for running Event Handler APIs locally with uvicorn or any ASGI server.

Changes

  • New HttpResolverAlpha class in aws_lambda_powertools/event_handler/http_resolver.py
  • Implements ASGI spec, no external dependencies
  • All existing features work: routing, middleware, validation, OpenAPI, CORS, exception handling
  • Marked as Alpha with runtime warning

User experience

from aws_lambda_powertools.event_handler import HttpResolverAlpha

app = HttpResolverAlpha(enable_validation=True)

@app.get("/hello/<name>")
def hello(name: str):
    return {"message": f"Hello, {name}!"}

# Run locally: uvicorn app:app --reload
# Deploy to Lambda: handler = app

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@leandrodamascena leandrodamascena requested a review from a team as a code owner January 6, 2026 17:19
@boring-cyborg boring-cyborg bot added documentation Improvements or additions to documentation event_handlers tests labels Jan 6, 2026
@pull-request-size pull-request-size bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jan 6, 2026
@github-actions github-actions bot added feature New feature or functionality and removed documentation Improvements or additions to documentation labels Jan 6, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

⚠️Large PR detected⚠️

Please consider breaking into smaller PRs to avoid significant review delays. Ignore if this PR has naturally grown to this size after reviews.

3 similar comments
@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

⚠️Large PR detected⚠️

Please consider breaking into smaller PRs to avoid significant review delays. Ignore if this PR has naturally grown to this size after reviews.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

⚠️Large PR detected⚠️

Please consider breaking into smaller PRs to avoid significant review delays. Ignore if this PR has naturally grown to this size after reviews.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

⚠️Large PR detected⚠️

Please consider breaking into smaller PRs to avoid significant review delays. Ignore if this PR has naturally grown to this size after reviews.

@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Jan 6, 2026
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Jan 6, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

⚠️Large PR detected⚠️

Please consider breaking into smaller PRs to avoid significant review delays. Ignore if this PR has naturally grown to this size after reviews.

@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 96.25668% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.71%. Comparing base (a3255e9) to head (73f3ca1).

Files with missing lines Patch % Lines
...s_lambda_powertools/event_handler/http_resolver.py 96.23% 2 Missing and 5 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #7913      +/-   ##
===========================================
- Coverage    96.72%   96.71%   -0.01%     
===========================================
  Files          275      276       +1     
  Lines        13214    13401     +187     
  Branches      1006     1030      +24     
===========================================
+ Hits         12781    12961     +180     
- Misses         325      327       +2     
- Partials       108      113       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Jan 6, 2026
@leandrodamascena leandrodamascena self-assigned this Jan 6, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

⚠️Large PR detected⚠️

Please consider breaking into smaller PRs to avoid significant review delays. Ignore if this PR has naturally grown to this size after reviews.

@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Jan 6, 2026
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Jan 6, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

⚠️Large PR detected⚠️

Please consider breaking into smaller PRs to avoid significant review delays. Ignore if this PR has naturally grown to this size after reviews.

@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Jan 6, 2026
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 6, 2026

@dreamorosi
Copy link
Contributor

I have some questions/concerns around whether this fits in the library.

Our first tenet says we focus on AWS Lambda runtime while this goes quite outside of that. I can see some value in having a regular resolver running locally for local development, but in the current shape the new resolver requires a code change which is creates a precedent in us adding a significant runtime implementation for a non-Lambda environment.

I am not opposing this feature, but I wonder if we can frame it differently or make it work differently.

As a quick win, I'd feel more comfortable if this was 1/ listed under the testing section of the docs, and 2/ named in a way that clearly conveys it's meant to be used for local testing only. In both cases my concern is that this gives the false impression that we want to support non-Lambda environments - which is not the case I hope.

Along the same lines, is there any way at all to get an existing resolver to work with the ASGI protocol when an env variable is set? I don't know the specifics but what I have in mind is basically customers using one of the already existing resolvers, and then when they set an env variable like POWERTOOLS_EVENT_HANDLER_ASGI the resolver works locally with this protocol.

Again, my goal here is mainly to make sure this is positioned in the correct way. Happy to discuss.

@leandrodamascena
Copy link
Contributor Author

Those are fair points. Thanks for raising them.

I have some questions/concerns around whether this fits in the library.

Our first tenet says we focus on AWS Lambda runtime while this goes quite outside of that. I can see some value in having a regular resolver running locally for local development, but in the current shape the new resolver requires a code change which is creates a precedent in us adding a significant runtime implementation for a non-Lambda environment.

Actually there is a minimal code change between local and Lambda

1/ Change the resolver
2/ Uncomment the Lambda Handler.

As a quick win, I'd feel more comfortable if this was 1/ listed under the testing section of the docs, and 2/ named in a way that clearly conveys it's meant to be used for local testing only. In both cases my concern is that this gives the false impression that we want to support non-Lambda environments - which is not the case I hope.

I am good to name this HttpResolverLocal and list it in the testing documentation, making it clear to use for test. This is a quick solution for clients who want to run it locally and create prototypes, especially those who are not onboarded in Lambda and are getting used to the Lambda programming model.

Tests, local run, CI and more.

Along the same lines, is there any way at all to get an existing resolver to work with the ASGI protocol when an env variable is set? I don't know the specifics but what I have in mind is basically customers using one of the already existing resolvers, and then when they set an env variable like POWERTOOLS_EVENT_HANDLER_ASGI the resolver works locally with this protocol.

Hmm no, there isn't because I'll change the code behavior and it's not ideal.

Again, my goal here is mainly to make sure this is positioned in the correct way. Happy to discuss.

Sure thing, I think your point about tests and naming make it clear.

WDYT?

Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, thanks for explaining.

I am ok with moving the section in the docs under testing plus renaming.

I'd suggest HttpResolverLocalDev to make it extra clear, but if it's too long HttpResolverLocal that you suggested + a call out in the docstring of the class is enough.

For future reference/readers, in similar cases where the boundary of what we build is not clear, we'll still want to evaluate whether something fits or not - so our tenet still stands.

@dreamorosi dreamorosi removed the request for review from anafalcao January 7, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

event_handlers feature New feature or functionality size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Add HttpResolverAlpha to run Event Handler APIs locally with ASGI servers

2 participants