pierrejeambrun commented on code in PR #43508:
URL: https://github.com/apache/airflow/pull/43508#discussion_r1832494793
##########
airflow/api_fastapi/core_api/routes/public/dag_run.py:
##########
@@ -121,22 +124,45 @@ async def patch_dag_run_state(
raise HTTPException(status.HTTP_404_NOT_FOUND, f"Dag with id {dag_id}
was not found")
if update_mask:
- if update_mask != ["state"]:
- raise HTTPException(
- status.HTTP_400_BAD_REQUEST, "Only `state` field can be
updated through the REST API"
- )
- else:
- update_mask = ["state"]
-
- for attr_name in update_mask:
+ update_mask_set = set(update_mask)
+ validation_errors = []
+
+ invalid_fields = update_mask_set - set(ALLOWED_FIELD_MASK)
+ if invalid_fields:
+ validation_errors.append(f"Invalid fields in update mask: {',
'.join(invalid_fields)}")
+
+ missing_fields = update_mask_set - invalid_fields -
patch_body.model_fields_set
+ if missing_fields:
+ validation_errors.append(f"Fields not present in request body: {',
'.join(missing_fields)}")
+
+ if validation_errors:
+ raise HTTPException(400, "; ".join(validation_errors))
Review Comment:
I think the implementation is different from the other PATCH request. Can
you take a look and confirm or adjust if the behavior / implem is no consistent
?
Even if there is a ticket out there to make all PATCH consistent I would
like to avoid adding yet another implementation specificities.
--
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]