Validate connection port bounds (0-65535) - #71684
Open
pulaksaha143 wants to merge 1 commit into
Open
Conversation
Fixes apache#68382 Airflow accepts invalid connection port numbers (-1, 999999) without validation. This adds validation at three layers: 1. Core `Connection` model via SQLAlchemy `@validates` 2. Task SDK `Connection` via `__init__` 3. REST API `ConnectionBody` via Pydantic `Field(ge=0, le=65535)`
pulaksaha143
requested review from
XD-DENG,
amoghrajesh,
ashb,
bugraoz93,
choo121600,
ephraimbuddy,
henry3260,
jason810496,
kaxil,
pierrejeambrun,
rawwar and
shubhamraj-git
as code owners
August 16, 2026 17:11
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.
Fixes #68382
Description
Airflow previously accepted invalid connection port numbers (-1, 999999) without validation. This PR adds strict validation (0-65535) at three critical layers to ensure bad data is never accepted or persisted:
Connectionmodel via SQLAlchemy@validatesConnectionvia__init__ConnectionBodyvia PydanticField(ge=0, le=65535)Testing
Added parameterized pytest coverage for:
Connectionmodel boundary rejections.Connectioninitialization and payload parsing./connections)POSTandPATCHreturning422 Unprocessable Entityfor out-of-bounds ports.