generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 453
Labels
Description
I'm trying to parse a POST based Form that has a multi-valued string property.
However this doesn't appear to work?. It does work for the string parameter, but not for the list.
Minimal example:
from typing import Annotated
from aws_lambda_powertools.event_handler import APIGatewayHttpResolver
from aws_lambda_powertools.event_handler.openapi.params import Form
from aws_lambda_powertools.utilities.typing import LambdaContext
app = APIGatewayHttpResolver(
enable_validation=True,
)
@app.post("/example")
def example(
param: Annotated[
str,
Form(),
],
param_list: Annotated[
list[str],
Form(),
] = []
):
pass
def lambda_handler(event: dict, context: LambdaContext) -> dict:
return app.resolve(event, context)
Tested by generating a dummy event to the lambda with body content like this:
import urlparse.parse
def test_example():
# Also tested with tuple form [("param_list", ["value1", "value2"])]
body = urlparse.parse.urlencode({
"param": "value",
"param_list": ["value1", "value2"]
}, doseq=True)
event = {
"headers": [
"accept": "application/json",
"content-type": "application/x-www-form-urlencoded"
],
...
"body": body
}
... rest of test elided
But I always get response code of 422 like this:
{
"statusCode": 422,
"detail": [
{
"loc": [
"body","param_list"
],
"type": "list_type"
}
]
}
Thanks!
Originally posted by @bdellegrazie in #7337
leandrodamascena
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Coming soon