-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Description
Apache Airflow Provider(s)
common-sql, mysql
Versions of Apache Airflow Providers
apache-airflow-providers-common-sql 1.17.0
apache-airflow-providers-mysql 5.6.1
Apache Airflow version
2.9.2+astro.1
Operating System
debian astronomer/astro-runtime:11.5.0
Deployment
Astronomer
Deployment details
This is an Astronomer-hosted deployment. Docker image is quay.io/astronomer/astro-runtime:11.5.0
What happened
DAGs that interact with MySqlHook started failing after apache-airflow-providers-common-sql was automatically upgraded from 1.16.0 to 1.17.0.
Here is an example error from the log:
[2024-09-24, 18:24:30 UTC] {taskinstance.py:2905} ERROR - Task failed with exception
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/airflow/models/taskinstance.py", line 465, in _execute_task
result = _execute_callable(context=context, **execute_callable_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/airflow/models/taskinstance.py", line 432, in _execute_callable
return execute_callable(context=context, **execute_callable_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/airflow/models/baseoperator.py", line 401, in wrapper
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/airflow/operators/python.py", line 235, in execute
return_value = self.execute_callable()
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/airflow/operators/python.py", line 252, in execute_callable
return self.python_callable(*self.op_args, **self.op_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/airflow/dags/sftp_handler.py", line 25, in getDBConnection
return MySqlHook(connection_name).get_conn()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/airflow/providers/mysql/hooks/mysql.py", line 75, in __init__
self.connection = kwargs.pop("connection", None)
^^^^^^^^^^^^^^^
AttributeError: property 'connection' of 'MySqlHook' object has no setter
requirements.txt had apache-airflow-providers-mysql with no version constraint.
apache-airflow-providers-mysql
Forcing downgrade to the previous version fixes the problem and allows the DAGs to run again:
apache-airflow-providers-mysql
apache-airflow-providers-common-sql <1.17
What you think should happen instead
Because we are including apache-airflow-providers-mysql without a version constraint, I would hope and expect that it would only bring in a version of apache-airflow-providers-common-sql that is compatible with the version of apache-airflow-providers-mysql that is being used. That does not appear to be happening here.
How to reproduce
- Install these exact dependency versions:
apache-airflow-providers-common-sql 1.17.0
apache-airflow-providers-mysql 5.6.1
- Inside a python operator, attempt to get an instance of a MysqlHook with a named connection:
conn = MySqlHook("my_named_mysql_connection").get_conn()
This will throw an AttributeError:
AttributeError: property 'connection' of 'MySqlHook' object has no setter
Anything else
This is consistently reproducible with the listed provider versions.
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