potiuk commented on code in PR #71092:
URL: https://github.com/apache/airflow/pull/71092#discussion_r3768238764


##########
providers/airbyte/src/airflow/providers/airbyte/hooks/airbyte.py:
##########
@@ -124,10 +131,25 @@ def create_api_session(self) -> AirbyteAPI:
                 }
             client = httpx.Client(mounts=mounts)
 
+        timeout = self.timeout if self.timeout is not None else 
self.conn["timeout"]
+        timeout_ms: int | None = None
+        if timeout is not None:
+            try:
+                timeout_ms = int(float(timeout) * 1000)
+            except (TypeError, ValueError):
+                timeout_ms = 0

Review Comment:
   Minor style point: setting `timeout_ms = 0` here so the `<= 0` check below 
raises works, but it routes a parse failure through a sentinel value. Raising 
the `ValueError` directly in the `except`, and keeping the range check 
separate, reads more plainly.



##########
providers/airbyte/src/airflow/providers/airbyte/hooks/airbyte.py:
##########
@@ -124,10 +131,25 @@ def create_api_session(self) -> AirbyteAPI:
                 }
             client = httpx.Client(mounts=mounts)
 
+        timeout = self.timeout if self.timeout is not None else 
self.conn["timeout"]
+        timeout_ms: int | None = None
+        if timeout is not None:
+            try:
+                timeout_ms = int(float(timeout) * 1000)
+            except (TypeError, ValueError):
+                timeout_ms = 0
+            if timeout_ms <= 0:
+                raise ValueError(
+                    f"Invalid Airbyte API request timeout {timeout!r}: 
expected a positive number of "
+                    f"seconds, set via the AirbyteHook 'timeout' parameter or 
the 'timeout' extra of "
+                    f"connection {self.airbyte_conn_id!r}"
+                )
+
         return AirbyteAPI(
             server_url=self.conn["host"],
             security=security,
             client=client,
+            timeout_ms=timeout_ms,

Review Comment:
   This covers the API operations, but not the OAuth token fetch: the SDK's 
client-credentials hook does 
`self.client.send(self.client.build_request("POST", token_url, ...))` with no 
timeout override, so that call keeps httpx's 5s default. On the loaded 
deployment you describe, the trigger can still fail — just on the token request 
instead of on `POST /v1/jobs`.
   
   Setting the timeout on the client itself covers both paths and removes the 
need for the ms conversion:
   
   ```python
   if self.conn["proxies"] or timeout is not None:
       client = httpx.Client(mounts=mounts, timeout=timeout if timeout is not 
None else 5.0)
   ```



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