Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forbid extra fields in BaseModel #44306

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Prev Previous commit
Small improvement
  • Loading branch information
pierrejeambrun committed Nov 29, 2024
commit 4b8806a481c1ac534792ab6cf7f5f739fd43af0f
8 changes: 0 additions & 8 deletions airflow/api_fastapi/core_api/datamodels/dags.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
ConfigDict,
computed_field,
field_validator,
model_validator,
)

from airflow.api_fastapi.core_api.base import BaseModel
Expand Down Expand Up @@ -92,13 +91,6 @@ def file_token(self) -> str:
serializer = URLSafeSerializer(conf.get_mandatory_value("webserver", "secret_key"))
return serializer.dumps(self.fileloc)

@model_validator(mode="before")
@classmethod
def remove_file_token(cls, data):
if isinstance(data, dict):
data.pop("file_token", None)
return data


class DAGPatchBody(BaseModel):
"""Dag Serializer for updatable bodies."""
Expand Down
2 changes: 1 addition & 1 deletion airflow/api_fastapi/core_api/routes/ui/dags.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def recent_dag_runs(
dag_response = DAGResponse.model_validate(dag)
dag_runs_by_dag_id[dag_id] = DAGWithLatestDagRunsResponse.model_validate(
{
**dag_response.dict(),
**dag_response.model_dump(exclude={"file_token"}),
"latest_dag_runs": [dag_run_response],
}
)
Expand Down