Repository navigation
User creation in Fab fails when no role specified #59963
Copy link
Copy link
Labels
Description
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:
(see Role field is empty)
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:
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
- I agree to follow this project's Code of Conduct
Reactions are currently unavailable
Activity
junaiddshaukat commentedon Dec 31, 2025
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!
Fix user creation in FAB fails when no role specified
junaiddshaukat commentedon Jan 1, 2026
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!
abhijeets25012-tech commentedon Jan 1, 2026
i would like to fix it
Fix user creation in FAB fails when no role specified (#60015)
jscheffl commentedon Jan 1, 2026
@abhijeets25012-tech oh, a small moment too late, was already merged. But there are other issues to grab as well :-D
Fix user creation in FAB fails when no role specified (apache#60015)
Fix user creation in FAB fails when no role specified (apache#60015)
Fix user creation in FAB fails when no role specified (apache#60015)
Fix user creation in FAB fails when no role specified (apache#60015)
Fix user creation in FAB fails when no role specified (apache#60015)