Skip to content

User creation in Fab fails when no role specified #59963

Closed

Description

@jscheffl

Apache Airflow version

3.1.5

If "Other Airflow 3 version" selected, which one?

No response

What happened?

While testing providers release on 2025-12-30 I noticed that when attempting to create a User in Fab and I miss to set the "Role" field I get a Ooops / HTTP 500 screen:

Image (see Role field is empty) Image

If a Role is selected it is working.

Stack trace from API Server:

2025-12-31T11:17:07.982595Z [error    ] Exception on /users/add [POST] [airflow.providers.fab.www.app] loc=app.py:1744
Traceback (most recent call last):
  File "/usr/python/lib/python3.12/site-packages/flask/app.py", line 2529, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/python/lib/python3.12/site-packages/flask/app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/python/lib/python3.12/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/python/lib/python3.12/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/python/lib/python3.12/site-packages/flask_appbuilder/security/decorators.py", line 151, in wraps
    return f(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/python/lib/python3.12/site-packages/flask_appbuilder/views.py", line 237, in add
    widget = self._add()
             ^^^^^^^^^^^
  File "/usr/python/lib/python3.12/site-packages/flask_appbuilder/baseviews.py", line 1241, in _add
    if form.validate():
       ^^^^^^^^^^^^^^^
  File "/usr/python/lib/python3.12/site-packages/wtforms/form.py", line 330, in validate
    return super().validate(extra)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/python/lib/python3.12/site-packages/wtforms/form.py", line 147, in validate
    if not field.validate(self, extra):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/python/lib/python3.12/site-packages/wtforms/fields/core.py", line 234, in validate
    stop_validation = self._run_validation_chain(form, chain)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/python/lib/python3.12/site-packages/wtforms/fields/core.py", line 254, in _run_validation_chain
    validator(form, self)
  File "/usr/python/lib/python3.12/site-packages/flask_appbuilder/security/forms.py", line 25, in roles_or_groups_required
    if not form["roles"].data and not form["groups"].data:
                                      ~~~~^^^^^^^^^^
  File "/usr/python/lib/python3.12/site-packages/wtforms/form.py", line 64, in __getitem__
    return self._fields[name]
           ~~~~~~~~~~~~^^^^^^
KeyError: 'groups'

What you think should happen instead?

Same like in Fab as released with Airflow 3.1.5 there should be a validation error generated, not a HTTP 500:

Image

How to reproduce

Use Fab apache-airflow-providers-fab==3.1.1rc1 or start on latest main via breeze start-airflow --python 3.12 --load-example-dags --backend postgres --executor LocalExecutor --answer y --auth-manager FabAuthManager

Log in as admin and go to Security->Users, add a user and miss-out to fill the "Roles" field.

Operating System

Linux

Versions of Apache Airflow Providers

Fab 3.1.1rc1 or latest main

Deployment

Other

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

Activity

  1. added theissue type on Dec 31, 2025
  2. junaiddshaukat commented on Dec 31, 2025

    @junaiddshaukat
    Contributor

    Hi @jscheffl , I’d like to work on this bug where user creation in Fab fails when no role is specified. I’ve read the issue details and understand the validation needs to be fixed instead of an HTTP 500 error. I plan to add a test and fix the validation logic in the Fab auth code. Please assign this to me. Thanks!

  3. added a commit that references this issue on Jan 1, 2026
    c4e90e0
  4. junaiddshaukat commented on Jan 1, 2026

    @junaiddshaukat
    Contributor

    Hi @jscheffl, I've opened a PR to fix this issue: #60015

    The fix adds a DataRequired validator to the roles field so users see a proper validation error instead of HTTP 500. I've also added a unit test and included a video demo in the PR.

    Would appreciate your review when you have time!

  5. abhijeets25012-tech commented on Jan 1, 2026

    @abhijeets25012-tech
    Contributor

    i would like to fix it

  6. added a commit that references this issue on Jan 1, 2026
    83afc02
  7. jscheffl commented on Jan 1, 2026

    @jscheffl
    ContributorAuthor

    i would like to fix it

    @abhijeets25012-tech oh, a small moment too late, was already merged. But there are other issues to grab as well :-D

  8. added a commit that references this issue on Jan 3, 2026
    59cad32
  9. added a commit that references this issue on Jan 9, 2026
    24ba244
  10. added a commit that references this issue on Feb 8, 2026
    5e994c6
  11. added a commit that references this issue on Mar 4, 2026
    38bae7a
  12. added a commit that references this issue on Mar 15, 2026
    ffb78e5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions