I've a step in my cicd pipeline that install airflow to test the dags loading. Since this morning has worked well. The steps are the following:
- apt update -y
- pip install --upgrade pip
- pip install apache-airflow==2.7.3
- export PATH=/root/.local/bin/:$PATH
- airflow db migrate
- export AIRFLOW_HOME=/root/airflow
- airflow variables import environments/local.json
- python3 -m pytest -s dags/
From this morning i got the following error during db initialization
File "/usr/local/lib/python3.11/site-packages/airflow/utils/db.py", line 700, in _get_flask_db AirflowDatabaseSessionInterface(app=flask_app, db=db, table="session", key_prefix="") TypeError: SqlAlchemySessionInterface.init() missing 6 required positional arguments: 'sequence', 'schema', 'bind_key', 'use_signer', 'permanent', and 'sid_length'
here the complete traceback:
File "/usr/local/bin/airflow", line 8, in <module>
sys.exit(main())
^^^^^^
File "/usr/local/lib/python3.11/site-packages/airflow/__main__.py", line 57, in main
args.func(args)
File "/usr/local/lib/python3.11/site-packages/airflow/cli/cli_config.py", line 49, in command
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/airflow/cli/commands/standalone_command.py", line 53, in entrypoint
StandaloneCommand().run()
File "/usr/local/lib/python3.11/site-packages/airflow/utils/providers_configuration_loader.py", line 55, in wrapped_function
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/airflow/cli/commands/standalone_command.py", line 69, in run
self.initialize_database()
File "/usr/local/lib/python3.11/site-packages/airflow/cli/commands/standalone_command.py", line 179, in initialize_database
db.initdb()
File "/usr/local/lib/python3.11/site-packages/airflow/utils/session.py", line 79, in wrapper
return func(*args, session=session, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/airflow/utils/db.py", line 733, in initdb
_create_db_from_orm(session=session)
File "/usr/local/lib/python3.11/site-packages/airflow/utils/db.py", line 718, in _create_db_from_orm
_create_flask_session_tbl(engine.url)
File "/usr/local/lib/python3.11/site-packages/airflow/utils/db.py", line 711, in _create_flask_session_tbl
db = _get_flask_db(sql_database_uri)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/airflow/utils/db.py", line 700, in _get_flask_db
AirflowDatabaseSessionInterface(app=flask_app, db=db, table="session", key_prefix="")
TypeError: SqlAlchemySessionInterface.__init__() missing 6 required positional arguments: 'sequence', 'schema', 'bind_key', 'use_signer', 'permanent', and 'sid_length'
locally i tried some different versions of sqlalchemy and flask without any progress
The issue is about the version of package Flask-Session. Temporary is limitation of airflow with Flask-Session==0.6.0
Solution:
pip install Flask-Session==0.5.0
Or you could use any version lower if you want but I suggest 0.5.0
There is github ticket for your issue if you want to investigate more: https://github.com/apache/airflow/issues/36883
jonny Appleseed's comments helped me to solve the issue by fixing the version of Flask-Version. see https://github.com/apache/airflow/pull/36895
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With