ColtenOuO commented on code in PR #72109:
URL: https://github.com/apache/airflow/pull/72109#discussion_r3866311650


##########
airflow-core/src/airflow/cli/commands/dag_command.py:
##########


Review Comment:
   When dag is not None (called from `DAG.cli()`), args.dag_id is overwritten 
with `dag.dag_id`, but `args.treat_dag_id_as_regex` isn't reset. The 
dag-specific parser has no way for the user to supply a pattern, yet a stray 
`--treat-dag-id-as-regex` flag will treat `dag.dag_id` itself as regex -- dots 
in `dag_ids` (e.g. `foo.bar`) then match unrelated DAGs like `fooXbar`.
   
   suggest forcing exact match when called with a dag:
   
   
   ```suggestion
   if dag is None and args.treat_dag_id_as_regex:
       query = query.where(DagModel.dag_id.regexp_match(args.dag_id))
   else:
       query = query.where(DagModel.dag_id == args.dag_id)
   ```
   
   I think we also need add a test with a `dag_id` containing regex 
metacharacters.
   
   



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