Skip to content

Bug: Path(alias=...) emits the Python argument name instead of the path template name regardless of whether alias is a closer match the path parameter #8803

Closed

Description

@jurique

Expected Behaviour

@app.get("/P/<camelId>")
def get_p(snake_id: Annotated[str, Path(alias="camelId")]):
    return {"id": snake_id}

Path(alias="camelId") on this route /P/<camelId> should produce an OpenAPI path parameter named camelId in order to match the {camelId} in the path template.

Current Behaviour

As of 3.39.0 the parameter is named after the Python argument (snake_id), not the alias. The path template stays /P/{camelId}, so the parameter name no longer matches it.

This appears to come from #8630 (closing #8583 , item 5), which says the emitted parameter name should match the path template. However in this scenario where the alias matches the template but the argument name doesn't it has the opposite effect.

Code snippet

import json
from typing import Annotated

from aws_lambda_powertools.event_handler import APIGatewayRestResolver
from aws_lambda_powertools.event_handler.openapi.params import Path

app = APIGatewayRestResolver(enable_validation=True)

@app.get("/P/<camelId>")
def get_p(snake_id: Annotated[str, Path(alias="camelId")]):
    return {"id": snake_id}

@app.get("/Q/<camelId>")
def get_q(camelId: Annotated[str, Path()]):
    return {"id": camelId}

schema = json.loads(app.get_openapi_json_schema())
for path, item in schema["paths"].items():
    print(path, [p["name"] for p in item["get"]["parameters"]])

Possible Solution

No response

Steps to Reproduce

Running the code in the Code snippet will produce the following output on 3.38.0:

/P/{camelId} ['camelId']
/Q/{camelId} ['camelId']

and the following on 3.39.0

/P/{camelId} ['snake_id']
/Q/{camelId} ['camelId']

Did you run the reproduction yourself?

No, this comes from reading the code

Powertools for AWS Lambda (Python) version

3.39.0

AWS Lambda function runtime

3.14

Packaging format used

PyPi

Debugging logs

Activity

  1. added
    bugSomething isn't working
    triagePending triage from maintainers
    on Nov 13, 2026
  2. boring-cyborg commented on Nov 13, 2026

    @boring-cyborg

    Thanks for opening your first issue here! We'll come back to you as soon as we can.
    In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

  3. powertools-for-aws-oss-automation commented on Nov 13, 2026

    @powertools-for-aws-oss-automation

    Thanks for opening your first issue here! We'll come back to you as soon as we can.
    In the meantime, check out our GitHub Discussions: Join the conversation

  4. leandrodamascena commented on Nov 14, 2026

    @leandrodamascena
    Contributor

    Thanks @jurique, confirmed, and it's a regression from #8630 in 3.39.0. Taking it for 3.41.0.

  5. added this to the 3.41.0 milestone on Nov 14, 2026
  6. powertools-for-aws-oss-automation commented on Nov 14, 2026

    @powertools-for-aws-oss-automation

    Warning

    This issue is now closed. Please be mindful that future comments are hard for our team to see.
    If you need more assistance, please either reopen the issue, or open a new issue referencing this one.
    If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't workingevent_handlerspending-releaseFix or implementation already in dev waiting to be released

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions