amoghrajesh commented on code in PR #63916:
URL: https://github.com/apache/airflow/pull/63916#discussion_r2958438491
##########
airflow-core/src/airflow/api_fastapi/execution_api/datamodels/taskinstance.py:
##########
@@ -325,19 +330,24 @@ def extract_dag_run_note(cls, data: Any) -> Any:
# Not a SQLAlchemy object, return as-is for Pydantic to handle
return data
+ values = {}
+
+ for field_name in cls.model_fields:
+ if field_name in insp.dict:
+ values[field_name] = insp.dict[field_name]
+ elif field_name == "state" and "_state" in insp.dict:
+ values["state"] = insp.dict["_state"]
+
+ if "consumed_asset_events" not in values:
+ values["consumed_asset_events"] = []
+
# Check if dag_run_note is already loaded (avoid lazy load on detached
instance)
- if "note" in insp.dict:
- note_value: str | None = insp.dict["note"]
- else:
- note_value = None
-
- # Convert to dict to avoid further lazy loading issues
- values = {
- field_name: getattr(data, field_name, None)
- for field_name in cls.model_fields
- if field_name != "note"
- }
- values["note"] = note_value
+ if "note" not in values:
+ if "dag_run_note" in insp.dict:
+ values["note"] = data.note
+ else:
+ values["note"] = None
Review Comment:
```python
if "note" not in values:
values["note"] = insp.dict.get("note")
# or
values = values | {"note": insp.dict.get("note") }
```
isn't valid cos we have different code?
--
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]