pierrejeambrun commented on code in PR #68777:
URL: https://github.com/apache/airflow/pull/68777#discussion_r3453555993


##########
airflow-core/src/airflow/models/connection_test.py:
##########
@@ -152,6 +160,7 @@ def __init__(
         self.login = login
         self.password = password
         self.schema = schema
+        self._validate_port(port, connection_id)

Review Comment:
   Putting this at the db layer level is probably too strict. This will break 
many setups.



##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/connections.py:
##########
@@ -192,6 +192,15 @@ class ConnectionBody(StrictBaseModel):
     login: str | None = Field(default=None)
     schema_: str | None = Field(None, alias="schema")
     port: int | None = Field(default=None)
+
+    @field_validator("port")
+    @classmethod
+    def validate_port(cls, v: int | None) -> int | None:
+        """Validate that port is within the valid TCP/UDP range (0-65535)."""
+        if v is not None and not (0 <= v <= 65535):
+            raise ValueError(f"Port must be between 0 and 65535, got {v}")
+        return v
+

Review Comment:
   That's not needed. The `Field` `gt` `le` param are enough to handle this.



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