Eason09053360 commented on code in PR #72941:
URL: https://github.com/apache/airflow/pull/72941#discussion_r4336227352


##########
airflow-core/src/airflow/cli/commands/task_command.py:
##########
@@ -600,9 +601,13 @@ def task_clear(args) -> None:
         dags = get_dags(args.bundle_name, args.dag_id, 
use_regex=args.dag_regex, from_db=True)
 
         if args.task_regex:
+            try:
+                task_pattern = re.compile(args.task_regex)
+            except re.error as e:
+                raise SystemExit(f"Invalid --task-regex {args.task_regex!r}: 
{e}")
             for idx, dag in enumerate(dags):
                 dags[idx] = dag.partial_subset(
-                    task_ids=args.task_regex,
+                    task_ids={task_id for task_id in dag.task_ids if 
task_pattern.search(task_id)},

Review Comment:
   Agree, but this predates the PR: on `main` a non-matching substring also 
clears nothing silently, and so does any empty clear (e.g. `--only-failed` with 
no failures). Airflow 2 printed "Nothing to clear." there (lost in #54383). I'd 
restore that for every case in a follow-up rather than error only on 
`--task-regex`. 
   Did these sounds ok with you?



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