pdebelak opened a new issue, #36054:
URL: https://github.com/apache/airflow/issues/36054
### Apache Airflow version
Other Airflow 2 version (please specify below)
### What happened
Running this command to reset a password via the CLI raises an exception:
```
$ flask --app airflow.www.app fab reset-password --username myusername
Password:
Repeat for confirmation:
Traceback (most recent call last):
File "/home/airflow/.local/bin/flask", line 8, in <module>
sys.exit(main())
File "/home/airflow/.local/lib/python3.8/site-packages/flask/cli.py", line
1050, in main
cli.main()
File "/home/airflow/.local/lib/python3.8/site-packages/click/core.py",
line 1078, in main
rv = self.invoke(ctx)
File "/home/airflow/.local/lib/python3.8/site-packages/click/core.py",
line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/airflow/.local/lib/python3.8/site-packages/click/core.py",
line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/airflow/.local/lib/python3.8/site-packages/click/core.py",
line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/airflow/.local/lib/python3.8/site-packages/click/core.py",
line 783, in invoke
return __callback(*args, **kwargs)
File
"/home/airflow/.local/lib/python3.8/site-packages/click/decorators.py", line
33, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/airflow/.local/lib/python3.8/site-packages/flask/cli.py", line
357, in decorator
return __ctx.invoke(f, *args, **kwargs)
File "/home/airflow/.local/lib/python3.8/site-packages/click/core.py",
line 783, in invoke
return __callback(*args, **kwargs)
File
"/home/airflow/.local/lib/python3.8/site-packages/flask_appbuilder/cli.py",
line 157, in reset_password
current_app.appbuilder.sm.reset_password(user.id, password)
File
"/home/airflow/.local/lib/python3.8/site-packages/airflow/auth/managers/fab/security_manager/override.py",
line 245, in reset_password
self.reset_user_sessions(user)
File
"/home/airflow/.local/lib/python3.8/site-packages/airflow/auth/managers/fab/security_manager/override.py",
line 255, in reset_user_sessions
flash(
File "/home/airflow/.local/lib/python3.8/site-packages/flask/helpers.py",
line 359, in flash
flashes = session.get("_flashes", [])
File "/home/airflow/.local/lib/python3.8/site-packages/werkzeug/local.py",
line 316, in __get__
obj = instance._get_current_object()
File "/home/airflow/.local/lib/python3.8/site-packages/werkzeug/local.py",
line 513, in _get_current_object
raise RuntimeError(unbound_message) from None
RuntimeError: Working outside of request context.
This typically means that you attempted to use functionality that needed
an active HTTP request. Consult the documentation on testing for
information about how to avoid this problem.
```
### What you think should happen instead
It should be possible to reset the password via the CLI. This is necessary
for when you need to reset your own password without knowing your current
password so you can't use the UI. I believe this means that the
`reset_user_sessions` function can't unconditionally use `flash` without
determining if it's running in a request context or not.
### How to reproduce
Run `flask --app airflow.www.app fab reset-password` with an existing
username via the CLI.
### Operating System
Debian GNU/Linux 11 (bullseye)
### Versions of Apache Airflow Providers
_No response_
### Deployment
Official Apache Airflow Helm Chart
### Deployment details
_No response_
### Anything else
_No response_
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]