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) |
, the
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) |
|
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?
Code of Conduct
Apache Airflow version
3.1.2
If "Other Airflow 2/3 version" selected, which one?
No response
What happened?
The
.split()method is called onconnection.hostwhich may beNoneAccording to Airflow's
Connectionmodel definitionairflow/airflow-core/src/airflow/models/connection.py
Line 136 in 4a083b4
hostfield type isstr | Noneand isnullable=Truein the database, soconnection.hostmay beNone.But the existing test
test_openlineage_methods_with_redshiftonly tests cases wherehostis a concrete string value, but does not testhost=None. The test allowsportto beNone(line 128), but thehostparameterization list does not include none values.What you think should happen instead?
No response
How to reproduce
airflow/airflow-core/src/airflow/models/connection.py
Line 136 in 4a083b4
airflow/providers/postgres/tests/unit/postgres/hooks/test_postgres.py
Lines 144 to 175 in 4a083b4
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?
Code of Conduct