You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "dj-wise-ronin (via GitHub)" <gi...@apache.org> on 2026/07/22 02:40:27 UTC
[PR] Fix Connection port field range validation (#68382) [airflow]
dj-wise-ronin opened a new pull request, #70208:
URL: https://github.com/apache/airflow/pull/70208
### Related Issue
Closes: #68382
### Description
Connection models in Apache Airflow accept integer values for the `port` field but do not enforce that the value is a valid network port in the range `[1, 65535]`.
This PR adds validation logic to connection ports at three layers:
1. **SQLAlchemy Connection model** validation via `@validates("port")` to ensure port numbers assigned are integers between 1 and 65535.
2. **Task SDK Connection model** validation in `__attrs_post_init__` to enforce range limits and format validation during standard instantiation and URI parsing.
3. **Pydantic API datamodel** validation using `Field(ge=1, le=65535)` on the REST API gateway connections schema.
Additionally, this PR refactors port validation logic into a shared validator in `airflow_shared.configuration.connection` and includes unit tests for both SQLAlchemy and Task SDK model implementations.
### PR Checklist
- [x] Related Issue: #68382
- [x] Unit tests added and passing
- [x] Code rebased on latest `upstream/main`
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Connection port field range validation (#68382) [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun closed pull request #70208: Fix Connection port field range validation (#68382)
URL: https://github.com/apache/airflow/pull/70208
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Connection port field range validation (#68382) [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on code in PR #70208:
URL: https://github.com/apache/airflow/pull/70208#discussion_r3659101705
##########
shared/configuration/src/airflow_shared/configuration/connection.py:
##########
@@ -0,0 +1,34 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+
+def parse_and_validate_port(port: int | str | None) -> int | None:
+ """Parse and validate connection port range."""
+ if port is None:
Review Comment:
'connection' validation isn't related to `configuration` it probably shouldn't live in that module.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org