rawwar commented on code in PR #43508:
URL: https://github.com/apache/airflow/pull/43508#discussion_r1825599818
##########
airflow/api_fastapi/core_api/routes/public/dag_run.py:
##########
@@ -90,21 +93,33 @@ async def patch_dag_run_state(
raise HTTPException(404, f"Dag with id {dag_id} was not found")
if update_mask:
- if update_mask != ["state"]:
- raise HTTPException(400, "Only `state` field can be updated
through the REST API")
+ for each in update_mask:
+ if each not in ALLOWED_FIELD_MASK:
+ raise HTTPException(400, f"Invalid field `{each}` in update
mask")
else:
- update_mask = ["state"]
+ update_mask = ALLOWED_FIELD_MASK
for attr_name in update_mask:
+ attr_value = getattr(patch_body, attr_name)
if attr_name == "state":
- state = getattr(patch_body, attr_name)
- if state == DAGRunPatchStates.SUCCESS:
+ if attr_value is None:
+ raise HTTPException(400, "state cannot be empty when it is
included in the update mask")
+ if attr_value == DAGRunPatchStates.SUCCESS:
set_dag_run_state_to_success(dag=dag, run_id=dag_run.run_id,
commit=True)
- elif state == DAGRunPatchStates.QUEUED:
+ elif attr_value == DAGRunPatchStates.QUEUED:
set_dag_run_state_to_queued(dag=dag, run_id=dag_run.run_id,
commit=True)
else:
set_dag_run_state_to_failed(dag=dag, run_id=dag_run.run_id,
commit=True)
-
+ elif attr_name == "note":
+ # Once Authentication is implemented in this FastAPI app,
+ # user id will be added when updating dag run note
+ # Refer to https://github.com/apache/airflow/issues/43534
+ if dag_run.dag_run_note is None:
+ dag_run.note = (attr_value, None)
+ else:
+ dag_run.dag_run_note.content = attr_value
Review Comment:
I did refer to legacy implementation and we are doing the exact same thing
there. I'll look into this and post here If I find anything
--
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]