You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Airflow 2.0报错:无法构建'Airflow.legacy_graph'端点URL

Airflow 2.0 解决"无法构建端点'Airflow.legacy_graph'的URL"错误

问题说明

Airflow 2.0已移除Airflow.legacy_graph端点,统一使用Airflow.graph替代,若系统仍调用旧端点会触发如下报错:

Traceback (most recent call last):
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/www/templates/airflow/dags.html", line 44, in top-level template code
{% elif curr_ordering_direction == 'asc' and request.args.get('sorting_key') == attribute_name %}
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/www/templates/airflow/main.html", line 21, in top-level template code
{% from 'airflow/_messages.html' import show_message %}
File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/templates/appbuilder/baselayout.html", line 2, in top-level template code
{% import 'appbuilder/baselib.html' as baselib %}
File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/templates/appbuilder/init.html", line 12, in top-level template code
{% block head_meta %}
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/www/templates/airflow/dags.html", line 63, in block 'head_meta'

File "/usr/local/lib/python3.8/site-packages/flask/helpers.py", line 370, in url_for
with_categories: bool = False, category_filter: t.Iterable[str] = ()
File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2216, in handle_url_build_error
subdomain = None
File "/usr/local/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
File "/usr/local/lib/python3.8/site-packages/flask/helpers.py", line 357, in url_for
# always in sync with the session object, which is not true for session
File "/usr/local/lib/python3.8/site-packages/werkzeug/routing.py", line 2179, in build
werkzeug.routing.BuildError: Could not build url for endpoint 'Airflow.legacy_graph'. Did you mean 'Airflow.graph' instead?

解决方案

  • 更新模板引用:如果使用自定义模板(如dags.html),找到所有调用url_for('Airflow.legacy_graph')的代码,替换为url_for('Airflow.graph')。

  • 清理模板缓存并重启服务:若用默认模板仍报错,执行以下命令清理缓存并重启webserver:

    # 清理模板缓存
    rm -rf /home/airflow/.local/lib/python3.8/site-packages/airflow/www/templates/airflow/__pycache__
    # 重启Airflow webserver
    airflow webserver restart
    
  • 检查第三方插件:若安装了第三方Airflow插件,确认插件是否适配Airflow 2.0版本。如果插件调用了旧端点,更新插件至兼容版本或修改插件代码中的端点引用。

内容的提问来源于stack exchange,提问作者Amit

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 05:45:31