amoghrajesh commented on code in PR #69873:
URL: https://github.com/apache/airflow/pull/69873#discussion_r3584753099
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/dag_run.py:
##########
@@ -222,7 +222,9 @@ def patch_dag_run(
data = patch_body.model_dump(include=fields_to_update, by_alias=True)
- for attr_name, attr_value_raw in data.items():
+ # Sort keys so that the "note" update happens before "state" update, so
that the listeners called inside
+ # `patch_dag_run_state()` already receive updated DagRun object with note.
+ for attr_name, attr_value_raw in sorted(data.items()):
Review Comment:
Using `sorted(data.items())` to force "note" before "state" couples
correctness to the field names' alphabetical order rather than expressing the
ordering intent explicitly. This works today because "note" < "state", but is a
trap for the next field added to `DAGRunPatchBody` & nothing would signal that
ordering matters.
I suggest using an explicit ordering or just processing "note" before the
loop which would be clearer and safer.
--
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]