eladkal commented on code in PR #38716:
URL: https://github.com/apache/airflow/pull/38716#discussion_r1550265521


##########
airflow/providers/apache/beam/operators/beam.py:
##########
@@ -364,11 +364,13 @@ def execute(self, context: Context):
 
     def execute_sync(self, context: Context):
         with ExitStack() as exit_stack:
-            gcs_hook = GCSHook(gcp_conn_id=self.gcp_conn_id)
             if self.py_file.lower().startswith("gs://"):
+                gcs_hook = GCSHook(gcp_conn_id=self.gcp_conn_id)

Review Comment:
   Can you please elaborate about this change?
   In https://github.com/apache/airflow/issues/38713 you showed traceback that 
connection isn't found
   ```
     File 
"/home/airflow/.local/lib/python3.8/site-packages/airflow/models/connection.py",
 line 514, in get_connection_from_secrets
       raise AirflowNotFoundException(f"The conn_id `{conn_id}` isn't defined")
   airflow.exceptions.AirflowNotFoundException: The conn_id 
`google_cloud_default` isn't defined
   ```
   
   I do not understand how this fix solves the issue.
   Why does it makes a different (for finding the connection) if the hook is 
initialized before or after the `if`?
   
   Connections should be defined before the code runs otherwirse the conn won't 
be found regardless of which part of the code invokes it.



-- 
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]

Reply via email to