-
Notifications
You must be signed in to change notification settings - Fork 15.9k
Open
Labels
Description
Apache Airflow version
3.1.2
If "Other Airflow 2/3 version" selected, which one?
No response
What happened?
The .split() method is called on connection.host which may be None
According to Airflow's Connection model definition
| host: Mapped[str | None] = mapped_column(String(500), nullable=True) |
host field type is str | None and is nullable=True in the database, so connection.host may be None.But the existing test
test_openlineage_methods_with_redshift only tests cases where host is a concrete string value, but does not test host=None. The test allows port to be None (line 128), but the host parameterization list does not include none values.
What you think should happen instead?
No response
How to reproduce
| host: Mapped[str | None] = mapped_column(String(500), nullable=True) |
airflow/providers/postgres/tests/unit/postgres/hooks/test_postgres.py
Lines 144 to 175 in 4a083b4
| def test_openlineage_methods_with_redshift( | |
| self, | |
| mocker, | |
| aws_conn_id, | |
| port, | |
| host, | |
| conn_cluster_identifier, | |
| expected_host, | |
| ): | |
| mock_aws_hook_class = mocker.patch("airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook") | |
| mock_conn_extra = { | |
| "iam": True, | |
| "redshift": True, | |
| } | |
| if aws_conn_id is not NOTSET: | |
| mock_conn_extra["aws_conn_id"] = aws_conn_id | |
| if conn_cluster_identifier is not NOTSET: | |
| mock_conn_extra["cluster-identifier"] = conn_cluster_identifier | |
| self.connection.extra = json.dumps(mock_conn_extra) | |
| self.connection.host = host | |
| self.connection.port = port | |
| # Mock AWS Connection | |
| mock_aws_hook_instance = mock_aws_hook_class.return_value | |
| mock_aws_hook_instance.region_name = "us-east-1" | |
| assert ( | |
| self.db_hook._get_openlineage_redshift_authority_part(self.connection) | |
| == f"{expected_host}:{port or 5439}" | |
| ) |
Operating System
macOS
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?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct