You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classVariablePostBody(BaseModel):
"""Request body schema for creating variables."""model_config=ConfigDict(from_attributes=True, populate_by_name=True, extra="forbid")
value: str|None=Field(serialization_alias="val")
description: str|None=Field(default=None)
@router.put("/{variable_key}", status_code=201)defput_variable(variable_key: str, body: VariablePostBody): ....
I get this error
FAILED tests/api_fastapi/execution_api/routes/test_variables.py::TestPutVariable::test_overwriting_existing_variable - cadwyn.exceptions.CadwynHeadRequestValidationError: We failed to migrate the request with version=2025-03-19. This means that there is some error in your migrations or schema structure that makes it impossible to migrate the request of that version to latest.
body={'val': 'new_value'}
errors=[
{
"type": "missing",
"loc": [
"body",
"value"
],
"msg": "Field required",
"input": {
"val": "new_value"
}
},
{
"type": "extra_forbidden",
"loc": [
"body",
"val"
],
"msg": "Extra inputs are not permitted",
"input": "new_value"
}
]
Hm... I'm afraid this one won't be easy to fix. Because currently we extract request body from the body parameter if it exists and directly if it doesn't exist. Body parameter in this case is VariablePostBody. So when we do VariablePostBody().model_dump(by_alias=True), we get a result that is incompatible with the validation of the latest version -- it's definitely a problem. However, if I set by_alias=False, then the case with alias="val" will stop working :)
Uh oh!
There was an error while loading. Please reload this page.
If I have this model and endpoint:
I get this error
I don't know quite why we're defining the alias like we are, but see original source here https://github.com/apache/airflow/blob/2500dcf20d2782d16da53ee857c0aab21bfdfbf2/airflow/api_fastapi/execution_api/datamodels/variable.py
Just defining them with
alias="val"
works.The text was updated successfully, but these errors were encountered: