Revanth14 commented on code in PR #68700:
URL: https://github.com/apache/airflow/pull/68700#discussion_r3439324411


##########
airflow-core/src/airflow/models/connection.py:
##########
@@ -219,6 +222,32 @@ def _validate_extra(extra, conn_id) -> None:
             raise ValueError(f"Encountered non-JSON in `extra` field for 
connection {conn_id!r}.")
         return None
 
+    @staticmethod
+    def _coerce_port(port: int | str | None) -> int | None:
+        if port is None:
+            return None
+        if isinstance(port, bool):
+            raise ValueError(f"Expected integer value for `port`, but got 
{port!r} instead.")
+        if isinstance(port, int):
+            return port
+        if isinstance(port, str):
+            try:
+                return int(port)
+            except ValueError:
+                raise ValueError(f"Expected integer value for `port`, but got 
{port!r} instead.") from None
+        raise ValueError(f"Expected integer value for `port`, but got {port!r} 
instead.")

Review Comment:
   Applied, thanks. I also made the same `match` / `case` change in the Task 
SDK `Connection` helper so the core and SDK implementations stay aligned.



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