### Apache Airflow version

2.4.3

### What happened

When I ran

`airflow tasks run example_bash_operator runme_0 2015-01-01`

I got the error

```
(venv) myusername@MacBook-Air airflow % airflow tasks run example_bash_operator runme_0 2015-01-01
[2022-11-14 23:49:19,228] {dagbag.py:537} INFO - Filling up the DagBag from /Users/myusername/airflow/dags
[2022-11-14 23:49:19,228] {cli.py:225} WARNING - Dag '\x1b[01mexample_bash_operator\x1b[22m' not found in path /Users/myusername/airflow/dags; trying path /Users/myusername/airflow/dags
[2022-11-14 23:49:19,228] {dagbag.py:537} INFO - Filling up the DagBag from /Users/myusername/airflow/dags
Traceback (most recent call last):
  File "/Users/myusername/airflow/venv/bin/airflow", line 8, in <module>
    sys.exit(main())
  File "/Users/myusername/airflow/venv/lib/python3.10/site-packages/airflow/__main__.py", line 39, in main
    args.func(args)
  File "/Users/myusername/airflow/venv/lib/python3.10/site-packages/airflow/cli/cli_parser.py", line 52, in command
    return func(*args, **kwargs)
  File "/Users/myusername/airflow/venv/lib/python3.10/site-packages/airflow/utils/cli.py", line 103, in wrapper
    return f(*args, **kwargs)
  File "/Users/myusername/airflow/venv/lib/python3.10/site-packages/airflow/cli/commands/task_command.py", line 366, in task_run
    dag = get_dag(args.subdir, args.dag_id, include_examples=False)
  File "/Users/myusername/airflow/venv/lib/python3.10/site-packages/airflow/utils/cli.py", line 228, in get_dag
    raise AirflowException(
airflow.exceptions.AirflowException: Dag 'example_bash_operator' could not be found; either it does not exist or it failed to parse.

```

### What you think should happen instead

Successful completion of the task

### How to reproduce

1. Create a Python venv based on Python 3.10
2. Follow the [Quick Start instructions](https://airflow.apache.org/docs/apache-airflow/stable/start.html) through `airflow tasks run example_bash_operator runme_0 2015-01-01`
3. The error should appear

### Operating System

MacOS 12.5.1

### Versions of Apache Airflow Providers

Not applicable

### Deployment

Other

### Deployment details

This is just on my local machine

### Anything else

_No response_

### Are you willing to submit PR?

- [ ] Yes I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)

"""Returns DAG of a given dag_id by looking up file location"""
    from airflow.models import DagBag, DagModel
    
    dag_model = DagModel.get_current(dag_id)
    if dag_model is None:
        raise AirflowException(
            f"Dag {dag_id!r} could not be found; either it does not exist or it failed to parse."
        )
    dagbag = DagBag(dag_folder=dag_model.fileloc)
    return dagbag.dags[dag_id]
def _search_for_dag_file(val: str | None) -> str | None:
    """
    Search for the file referenced at fileloc.
    By the time we get to this function, we've already run this `val` through `process_subdir`
    and loaded the DagBag there and came up empty.  So here, if `val` is a file path, we make
    a last ditch effort to try and find a dag file with the same name in our dags folder. (This
    avoids the unnecessary dag parsing that would occur if we just parsed the dags folder).
    If `val` is a path to a file, this likely means that the serializing process had a dags_folder
    equal to only the dag file in question. This prevents us from determining the relative location.
    And if the paths are different between worker and dag processor / scheduler, then we won't find
    the dag at the given location.
    """
    if val and Path(val).suffix in (".zip", ".py"):
        matches = list(Path(settings.DAGS_FOLDER).rglob(Path(val).name))
        if len(matches) == 1:
            return matches[0].as_posix()
    return None
def get_dag(