pierrejeambrun commented on code in PR #45349:
URL: https://github.com/apache/airflow/pull/45349#discussion_r1922112677


##########
airflow/ui/src/queries/useClearTaskInstances.ts:
##########
@@ -60,6 +60,7 @@ export const useClearTaskInstances = ({
       onSuccessDryRun(data);
     } else {
       const taskInstanceKeys = (variables.requestBody.task_ids ?? [])
+        .filter((taskId): taskId is string => typeof taskId === "string")

Review Comment:
   I don't think this should be handled like this.
   
   We should update this code to be able to clear a single mapped task 
instance. Therefore the task_id could be `['task_id', mapped_index]` and we 
need to handle that.



##########
airflow/api_fastapi/core_api/datamodels/task_instances.py:
##########
@@ -168,7 +168,7 @@ class ClearTaskInstancesBody(BaseModel):
     only_failed: bool = True
     only_running: bool = False
     reset_dag_runs: bool = True
-    task_ids: list[str] | None = None
+    task_ids: list[str | list[str]] | None = None

Review Comment:
   This will not work for clearing multiple mapped index. We are currently 
receiving a 500 internal error.
   
   `["task_id", "0", "1"]`, etc... I think we should limit this to a tuple of 
`[string, int]` and let the user explode the call if he needs to clear multiple 
mapped index. `[["task_id", 0], ["task_id", 1]]`
   
   Or we can keep it like this, but we need to type it better, something like:
   `tuple[str, Unpack[tuple[int, ...]]]` but we need to verify that the openapi 
/ doc is correct and that the front-end generated code looks good.



##########
tests/api_fastapi/core_api/routes/public/test_task_instances.py:
##########
@@ -1839,6 +1839,31 @@ class 
TestPostClearTaskInstances(TestTaskInstanceEndpoint):
                 2,
                 id="dry_run default",
             ),
+            pytest.param(
+                "example_python_operator",
+                [
+                    {"logical_date": DEFAULT_DATETIME_1, "state": 
State.FAILED},
+                    {
+                        "logical_date": DEFAULT_DATETIME_1 + 
dt.timedelta(days=1),
+                        "state": State.FAILED,
+                    },
+                    {
+                        "logical_date": DEFAULT_DATETIME_1 + 
dt.timedelta(days=2),
+                        "state": State.FAILED,
+                    },
+                    {
+                        "logical_date": DEFAULT_DATETIME_1 + 
dt.timedelta(days=3),
+                        "state": State.FAILED,
+                    },
+                ],
+                "example_python_operator",
+                {
+                    "dry_run": False,
+                    "task_ids": [["print_the_context", "0"], "sleep_for_1"],

Review Comment:
   Why are we passing the mapped index as a string ? Shouldn't this be an 
integer ? 



-- 
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