bjankie1 commented on code in PR #32016:
URL: https://github.com/apache/airflow/pull/32016#discussion_r1237031607
##########
airflow/providers/snowflake/hooks/snowflake.py:
##########
@@ -216,7 +216,16 @@ def _get_conn_params(self) -> dict[str, str | None]:
"Please remove one."
)
elif private_key_file:
- private_key_pem = Path(private_key_file).read_bytes()
+ private_key_file_path = Path(private_key_file)
+ if not private_key_file_path.is_file() or
private_key_file_path.stat().st_size == 0:
+ raise AirflowException(
+ "The private_key_file path points to an empty or invalid
file."
+ )
Review Comment:
I checked also that for system `st_size` reports size as 0 therefore it's an
alternative way of checking if this is a valid file. On top of that it doesn't
make sense to pass an empty file in this case.
##########
airflow/providers/snowflake/hooks/snowflake.py:
##########
@@ -216,7 +216,16 @@ def _get_conn_params(self) -> dict[str, str | None]:
"Please remove one."
)
elif private_key_file:
- private_key_pem = Path(private_key_file).read_bytes()
+ private_key_file_path = Path(private_key_file)
+ if not private_key_file_path.is_file() or
private_key_file_path.stat().st_size == 0:
+ raise AirflowException(
+ "The private_key_file path points to an empty or invalid
file."
+ )
Review Comment:
I checked also that for system `st_size` reports size as 0 therefore it's an
alternative way of checking if this is a valid file. On top of that it doesn't
make sense to pass an empty file in this case.
--
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]