Repository navigation
Bug: Bedrock Agent kwargs and null content type, AppSync decorator returns None and context leak, Router duplicates, Function URL base path, Depends() with a class #8584
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't workingevent_handlersgood first issueGood for newcomersGood for newcomerstriagePending triage from maintainersPending triage from maintainers
Milestone
Description
Expected Behaviour
- Bedrock Agent: only path parameters are injected as kwargs when validation is off, and a
Responsewithout content type produces a valid media type key. - AppSync Events: a decorator with an invalid path still returns the function. AppSync:
app.contextis cleared after every invocation, including when an exception handler runs. Routerwarns on duplicate routes like the resolver does;LambdaFunctionUrlResolver._get_base_pathchecks the path;Depends(SomeClass)honours the__init__signature.
Current Behaviour
BedrockAgentResolver(enable_validation=False)passes every event parameter as a kwarg (bedrock_agent.py:350). A query parameter not in the handler signature raisesTypeError: unexpected keyword argument. With validation on the middleware rewrites_route_argsand masks it.- A
Responsewithout content type produces"responseBody": {"null": {...}}(bedrock_agent.py:52). @app.on_publish("/default/*/sub")warns "will be skipped" and returnsNone, so the decorated function disappears (events_appsync/_registry.py:56).AppSyncResolver.resolve()returns the exception handler result beforeclear_context(), soapp.contextleaks into the next invocation (appsync.py:160). The docs say context is cleared after each invocation.Routersilently overwrites a duplicate route, last wins (api_gateway.py:3185). The resolver warns and keeps the first.LambdaFunctionUrlResolver._get_base_pathcomparesrequest_context.http.methodinstead of.path(lambda_function_url.py:57). Unreachable today since Function URLs only use$default, but it is a typo.Depends(SomeClass)usesget_type_hints(cls), which returns class-level annotations, not__init__parameters (depends.py:121, 201). A class dependency cannot receiveRequestor a nestedDepends:DependencyResolutionError: Svc.__init__() missing 1 required positional argument.
Code snippet
import warnings
from typing import Annotated
from aws_lambda_powertools.event_handler import APIGatewayRestResolver, AppSyncEventsResolver, AppSyncResolver, BedrockAgentResolver, Depends, Request, Response
from aws_lambda_powertools.event_handler.api_gateway import Router
from tests.functional.utils import load_event
ev = load_event("bedrockAgentEventWithPathParams.json")
ev["parameters"].append({"type": "string", "name": "verbose", "value": "true"})
b = BedrockAgentResolver(enable_validation=False)
@b.get("/claims/<claim_id>", description="d")
def g(claim_id: str): return {"claim_id": claim_id}
b.resolve(ev, None) # TypeError: g() got an unexpected keyword argument 'verbose'
events = AppSyncEventsResolver()
with warnings.catch_warnings():
warnings.simplefilter("ignore")
@events.on_publish("/default/*/sub")
def h4(payload): return payload
print(h4) # None
gql = AppSyncResolver()
@gql.exception_handler(ValueError)
def eh(e): return {"error": str(e)}
@gql.resolver(type_name="Mutation", field_name="createSomething")
def c(**kw): gql.append_context(x=1); raise ValueError("bad")
gql.resolve(load_event("appSyncDirectResolver.json"), None); print(gql.context) # {'x': 1}
router = Router()
@router.get("/my/path")
def a(): return {"fn": "a"}
@router.get("/my/path")
def bb(): return {"fn": "b"}
app = APIGatewayRestResolver(); app.include_router(router) # no warning
print(app.resolve(load_event("apiGatewayProxyEvent.json"), None)["body"]) # {"fn":"b"}
class Svc:
def __init__(self, request: Request): self.path = request.resolved_event.path
app2 = APIGatewayRestResolver()
@app2.get("/my/path")
def h(svc: Annotated[Svc, Depends(Svc)]): return {"path": svc.path}
app2.resolve(load_event("apiGatewayProxyEvent.json"), None) # DependencyResolutionErrorPossible Solution
Filter Bedrock kwargs to match.groupdict() keys and default the content type to application/json; return func in the AppSync Events registry; wrap AppSync clear_context() in try/finally; warn in Router.route on duplicate keys; use .http.path in Function URL; inspect fn.__init__ when the dependency is a class.
Steps to Reproduce
Run the snippet above with the tests/events fixtures. Full context in #8576.
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.13
Packaging format used
PyPi
Debugging logs
Warning
This issue is ready to be picked up, by humans or by agents. If you want it, comment here first so we can assign it to you, and please take only one or two issues at a time so others can join in too. Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingevent_handlersgood first issueGood for newcomersGood for newcomerstriagePending triage from maintainersPending triage from maintainers
Type
Projects
- StatusShow more project fieldsTriage
Activity
vishwakt commentedon Oct 19, 2026
I'll take this one. I verified all seven against today's develop before claiming and they reproduce as described. Planning a single PR with one fix plus test per bug, happy to split it up if you'd rather review them separately.
leandrodamascena commentedon Oct 19, 2026
Hey @vishwakt pls go ahead, thanks for checking all seven against develop first. Will review #8629.