Fix Connection port field range validation (#68382) - #70208
Open
dj-wise-ronin wants to merge 2 commits into
Open
Fix Connection port field range validation (#68382)#70208dj-wise-ronin wants to merge 2 commits into
dj-wise-ronin wants to merge 2 commits into
Conversation
Signed-off-by: DeAngelo Jackson-Adams <dj@wiseronin.com>
…dk and core Signed-off-by: DeAngelo Jackson-Adams <dj@wiseronin.com>
dj-wise-ronin
requested review from
XD-DENG,
amoghrajesh,
ashb,
bugraoz93,
choo121600,
ephraimbuddy,
henry3260,
jason810496,
kaxil,
pierrejeambrun,
potiuk,
rawwar and
shubhamraj-git
as code owners
July 22, 2026 02:40
Member
There was a problem hiding this comment.
What I'm affraid is that if a user has a wrong connection in their current database, upgrading with this patch mean that the task sdk endpoint will fail at runtime. Basically a task could now fail because of this. (public API though is validating only for 'write' operations, which sounds good).
We should probably do the same on the task sdk, enforce validation on 'write' only and let 'read' as it is today.
I would keep validation from 3, and delete 1 and 2 related code as a safer approach.
Comment on lines
+19
to
+22
|
|
||
| def parse_and_validate_port(port: int | str | None) -> int | None: | ||
| """Parse and validate connection port range.""" | ||
| if port is None: |
Member
There was a problem hiding this comment.
'connection' validation isn't related to configuration it probably shouldn't live in that module.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
Closes: #68382
Description
Connection models in Apache Airflow accept integer values for the
portfield 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:
@validates("port")to ensure port numbers assigned are integers between 1 and 65535.__attrs_post_init__to enforce range limits and format validation during standard instantiation and URI parsing.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.connectionand includes unit tests for both SQLAlchemy and Task SDK model implementations.PR Checklist
upstream/main