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


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

Review Comment:
   I don't think we should use `is` keyword. That's only for Type Guard I don't 
think we should need that.



##########
tests/api_fastapi/core_api/routes/public/test_task_instances.py:
##########
@@ -1841,6 +1841,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"],
+                },
+                2,
+                id="clear mapped task and unmapped tasks together",
+            ),
         ],
     )
     def test_should_respond_200(

Review Comment:
   Maybe add a test for the `422` returned by `["some_task_id", 1, 2]`



##########
airflow/ui/src/queries/useClearTaskInstances.ts:
##########
@@ -60,13 +60,21 @@ export const useClearTaskInstances = ({
       onSuccessDryRun(data);
     } else {
       const taskInstanceKeys = (variables.requestBody.task_ids ?? [])
+        .filter(
+          (taskId): taskId is string | [string, number] =>
+            typeof taskId === "string" || Array.isArray(taskId),
+        )
         .map((taskId) => {
+          // Determine the actual task_id
+          const actualTaskId = Array.isArray(taskId) ? taskId[0] : taskId;

Review Comment:
   As we implemented the fallback approach, we need to deduplicate here. 
because `taskId[0]` could possibly be the same task_id.
   
   And we don't want to pass duplicated key to invalidate cache.



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