ecodina opened a new issue, #61850:
URL: https://github.com/apache/airflow/issues/61850
### Apache Airflow version
3.1.7
### If "Other Airflow 3 version" selected, which one?
_No response_
### What happened?
The "External DAG" that appears in the details page of an ExternalTaskSensor
instance contains a wrong URL.
It assumes that the task is waiting for a run with the exact same logical
date even if you specify another logical date.
### What you think should happen instead?
_No response_
### How to reproduce
1. Create a Dag with a Cron trigger of (example) `35 22 * * *` that contains
an EmptyOperator
2. Create a Dag with a Cron trigger of (example) `40 22 * * *` that contains
an ExternalTaskSensor that waits for Dag 1 and uses a function for
`execution_date_fn` similar to :
```python
def get_last_execution_date_of_dag(logical_date: datetime.datetime,
**kwargs):
import airflow_client.client
from airflow.configuration import conf
from myprovider.hooks.api_token import AirflowAPITokenHook # Won't
work, you need to obtain the token somehow
hook =
AirflowAPITokenHook(airflow_api_token_conn_id="airflow_api_token_default")
token = hook.get_token()
base_url = conf.get("api", "base_url")
dag_id = kwargs["task"].external_dag_id
configuration = airflow_client.client.Configuration(
host=base_url, access_token=token
)
with airflow_client.client.ApiClient(configuration) as api_client:
api_instance = airflow_client.client.DagRunApi(api_client)
api_response = api_instance.get_dag_runs(
dag_id, logical_date_lte=logical_date, limit=1,
order_by=["-logical_date"]
)
if not api_response.dag_runs or len(api_response.dag_runs) == 0:
raise ValueError(
f"No previous dag_run found for DAG {dag_id} before
{logical_date}. Please ensure the parent Dag has at least one run before this
date."
)
last_dag_run = api_response.dag_runs[0]
parent_logical_date = last_dag_run.logical_date
print(
f"Found last dag_run for DAG {dag_id} before {logical_date}:
{parent_logical_date}"
)
return parent_logical_date
```
When Dag 2 gets executed, you'll see this line in the log:
```
Found last dag_run for DAG dag1 before 2026-02-11 22:35:00+00:00: 2026-02-11
22:30:00+00:00
```
Which is correct.
However, the link that is generated is:
```
https://myairflow.example.com/dags/dag1/runs/scheduled__2026-02-11T22:35:00+00:00
```
Which contains the run ID of Dag2, not Dag1.
### Operating System
Debian GNU/Linux 12 (bookworm)
### Versions of Apache Airflow Providers
_No response_
### Deployment
Docker-Compose
### Deployment details
_No response_
### 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)
--
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]