**Reproduce on main:**
- Run a DAG
- Rename the DAG
- Wait for dag file processor to remove the deleted DAG and add the new one. (Old Dag should not appear on the home page anymore)
- Go to the Browse DAGRUN page.
- Click on a DagRun of the deleted DAG, as if you want to see the 'details/grid' of that old dag run

More info and screenshots here:
https://github.com/notifications#discussioncomment-6898570

![image](https://github.com/apache/airflow/assets/14861206/7af81643-6278-4d90-a20f-6aa7b259ce59)



"""Redirects to external log."""
        dag_id = request.args.get("dag_id")
        task_id = request.args.get("task_id")
        execution_date = request.args.get("execution_date")
        dttm = _safe_parse_datetime(execution_date)
        map_index = request.args.get("map_index", -1, type=int)
        try_number = request.args.get("try_number", 1)
        ti = session.scalar(
            select(models.TaskInstance)
            .filter_by(dag_id=dag_id, task_id=task_id, execution_date=dttm, map_index=map_index)
            .limit(1)
        )
        if not ti:
            flash(f"Task [{dag_id}.{task_id}] does not exist", "error")
            return redirect(url_for("Airflow.index"))
        task_log_reader = TaskLogReader()
        if not task_log_reader.supports_external_link:
            flash("Task log handler does not support external links", "error")
            return redirect(url_for("Airflow.index"))
        handler = task_log_reader.log_handler
        url = handler.get_external_log_url(ti, try_number)
        return redirect(url)
    @expose("/task")
    @auth.has_access_dag("GET", DagAccessEntity.TASK_INSTANCE)
    @action_logging
    @provide_session
    def task(self, session: Session = NEW_SESSION):