-
First Check
Commit to Help
Example Codefrom fastapi import Form
from typing import Annotated
from fastapi import FastAPI
app = FastAPI()
@app.post("/")
def read_root(
form_session_id: Annotated[str | None, Form(alias="sessionid")] = None,
):
return form_session_idDescriptionSending a request with > curl --form sessionid=123qwe http://127.0.0.1:8000/
nullWith Interestingly with @app.post("/")
def read_root(
form_session_id: Annotated[str | None, Form(alias="sessionid")] = None,
sessionid: Annotated[str | None, Form()] = None,
):
return form_session_id(note that im not returning the blind sessionid but the form_session_id, anyhow this makes the difference). Operating SystemLinux, macOS Operating System DetailsNo response FastAPI Version0.113.0 Pydantic Version2.9.0 Python Version3.12.1 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
@fnep Yes, you are right. I think this regression problem lies in this line. I think this should be if value is not None:
values[field.alias] = valuebecause |
Beta Was this translation helpful? Give feedback.
-
|
@fnep I see a few complaints about the regression in version |
Beta Was this translation helpful? Give feedback.
@fnep Yes, you are right. I think this regression problem lies in this line. I think this should be
because
aliasinfirst_field_infois set to alias if we specified inForm(alias=...), and if not, field name is set to alias infirst_field_info. Can you patch a local fastapi install with that change and give it a try?