john-rodriguez-mgni commented on PR #61483:
URL: https://github.com/apache/airflow/pull/61483#issuecomment-3954071746

   @pierrejeambrun it seems that all 10 CI failures failures trace back to the 
same root cause; the `allowed_run_types` field was added to DAGResponse on 
the`main` branch after this branch was created. Since the optimization switches 
from DAGResponse.model_validate(dag) (which dynamically picks up all model 
fields from the ORM object) to an explicit dict construction, the new field is 
missing from the dict, causing a `ValidationError: allowed_run_types - Field 
required on DAGWithLatestDagRunsResponse`. The 7 API/Serialization suite 
failures hit this directly, and the 3 UI e2e failures (Chromium/Firefox/WebKit) 
are a downstream consequence — the /ui/dags endpoint returns 500, so the 
dags-list e2e tests can't render anything.
   
   The immediate fix is simple — add `"allowed_run_types": 
dag.allowed_run_types` to the dict. However, this highlights a fragility in the 
explicit-field approach: any new field added to DAGResponse requires a 
corresponding update here, which is easy to miss. To make this more robust, we 
could build the dict dynamically from DAGResponse.model_fields which iterates 
over the model's field definitions to pull attributes from the ORM object, so 
new fields are picked up automatically. The dict construction is still just 
cheap `getattr` calls, and there's still only one model_validate call. Overhead 
of iterating model_fields is negligible compared to Pydantic validation.
   
   Thoughts?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to