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

Apache Airflow安全页签功能报错求助(RHEL 8.8全新安装)

Apache Airflow Security页面功能报错修复方案

问题概述

在RHEL 8.8系统全新安装Apache Airflow后,点击Security页签下的List Users、List Roles、User Statistics或Permissions选项时,均触发500内部服务器错误,未修改过任何Airflow源码。

报错信息

页面表现

  • 访问上述功能时,页面返回500 Internal Server Error,提示服务器处理请求时发生意外错误
  • 以Permissions功能为例,访问路径/permissions/list/时同样返回500错误

核心日志

[2023-10-19T21:10:42.275+0300] {app.py:1744} ERROR - Exception on /permissions/list/ [GET]
Traceback (most recent call last):
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/flask/app.py", line 2529, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/flask/app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/flask_appbuilder/security/decorators.py", line 137, in wraps
    return f(self, *args, **kwargs)
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/flask_appbuilder/views.py", line 555, in list
    return self.render_template(
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/flask_appbuilder/baseviews.py", line 343, in render_template
    return render_template(
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/flask/templating.py", line 147, in render_template
    return _render(app, template, context)
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/flask/templating.py", line 130, in _render
    rv = template.render(context)
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/flask_appbuilder/templates/appbuilder/general/model/list.html", line 2, in top-level template code
    {% import 'appbuilder/general/lib.html' as lib %}
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/flask_appbuilder/templates/appbuilder/base.html", line 1, in top-level template code
    {% extends base_template %}
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/airflow/www/templates/airflow/main.html", line 21, in top-level template code
    {% from 'airflow/_messages.html' import show_message %}
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/flask_appbuilder/templates/appbuilder/baselayout.html", line 2, in top-level template code
    {% import 'appbuilder/baselib.html' as baselib %}
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/flask_appbuilder/templates/appbuilder/init.html", line 42, in top-level template code
    {% block body %}
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/flask_appbuilder/templates/appbuilder/baselayout.html", line 19, in block 'body'
    {% block content %}
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/flask_appbuilder/templates/appbuilder/general/model/list.html", line 7, in block 'content'
    {% block list_search scoped %}
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/flask_appbuilder/templates/appbuilder/general/model/list.html", line 8, in block 'list_search'
    {% call lib.accordion_tag("accordion1",_("Search"), False) %}
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/jinja2/runtime.py", line 777, in _invoke
    rv = self._func(*arguments)
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/flask_appbuilder/templates/appbuilder/general/lib.html", line 304, in template
    {{ caller() }}
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/jinja2/runtime.py", line 777, in _invoke
    rv = self._func(*arguments)
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/flask_appbuilder/templates/appbuilder/general/model/list.html", line 9, in template
    {{ widgets.get('search')()|safe }}
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/flask_appbuilder/widgets.py", line 115, in __call__
    form_fields[col] = self.template_args["form"][col]()
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/wtforms/fields/core.py", line 176, in __call__
    return self.meta.render_field(self, kwargs)
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/wtforms/meta.py", line 64, in render_field
    return field.widget(field, **render_kw)
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/flask_appbuilder/fieldwidgets.py", line 160, in __call__
    return super(Select2Widget, self).__call__(field, **kwargs)
  File "/home/roxox/airflow_venv/lib/python3.10/site-packages/wtforms/widgets/core.py", line 365, in __call__
    for val, label, selected, render_kw in field.iter_choices():
ValueError: not enough values to unpack (expected 4, got 3)

修复步骤

该错误源于wtforms版本与flask-appbuilder版本不兼容:wtforms 3.0+修改了iter_choices()的返回格式,从3元组改为4元组,但旧版flask-appbuilder未适配此变化。

  1. 激活Airflow虚拟环境:
    source /home/roxox/airflow_venv/bin/activate
    
  2. 降级wtforms到兼容版本:
    pip install wtforms==2.3.3
    
  3. 重启Airflow服务:
    airflow webserver --restart
    airflow scheduler --restart
    

验证:重启后再次访问Security页签的相关功能,页面可正常加载。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.08 03:19:54