sunank200 commented on issue #31551: URL: https://github.com/apache/airflow/issues/31551#issuecomment-1564191480
@dstandish @hussein-awala @phanikumv This is a bug in the current implementation as per the [PR](https://github.com/apache/airflow/pull/28187). When user passes the following as part of redshift connection, it would break: ``` { "iam": true, "cluster_identifier": "redshift-cluster-1", "port": 5439, "region": "us-east-1", "db_user": "awsuser", "database": "dev", "profile": "default" } ``` The following image shows that the `host` is not set in the connection but `cluster_identifier` is set.  Even though the `cluster_identifier` is set here this would break with the following error on the [line](https://github.com/apache/airflow/blob/main/airflow/providers/amazon/aws/hooks/redshift_sql.py#L107) as host is not set because `conn.host` is evaluated first and when we split it to `NoneType` object it would throw attribute error. ``` conn.extra_dejson.get("cluster_identifier", conn.host.split(".")[0]) ```  Following is the test we did. ``` >>> conn.extra_dejson.get("cluster_identifier") PyDev console: starting. '<REDSHIFT_CLUSTER_IDENTIFIER>' >>> conn.extra_dejson.get("cluster_identifier", None) '<REDSHIFT_CLUSTER_IDENTIFIER>' >>> conn.host >>> conn.extra_dejson.get("cluster_identifier", conn.host.split(".")[0]) Traceback (most recent call last): File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_exec2.py", line 3, in Exec exec(exp, global_vars, local_vars) File "<input>", line 1, in <module> AttributeError: 'NoneType' object has no attribute 'split' ``` Thanks @pankajkoti for your support with the connection details we use in astro-sdk and debugging. ## Conclusion: This is a bug in the current implementation for all users when `host` is not set in the [connection](https://airflow.apache.org/docs/apache-airflow-providers-amazon/stable/connections/redshift.html) (not only for default connections). This would require an null check for `conn.host`. -- 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]
