Skip to content

Validate connection port bounds (0-65535) - #71684

Open
pulaksaha143 wants to merge 1 commit into
apache:mainfrom
pulaksaha143:fix-connection-port-validation-68382
Open

Validate connection port bounds (0-65535)#71684
pulaksaha143 wants to merge 1 commit into
apache:mainfrom
pulaksaha143:fix-connection-port-validation-68382

Conversation

@pulaksaha143

Copy link
Copy Markdown

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:

  1. Core Connection model via SQLAlchemy @validates
  2. Task SDK Connection via __init__
  3. REST API ConnectionBody via Pydantic Field(ge=0, le=65535)

Testing

Added parameterized pytest coverage for:

  • SQLAlchemy Connection model boundary rejections.
  • Task SDK Connection initialization and payload parsing.
  • FastAPI public REST API (/connections) POST and PATCH returning 422 Unprocessable Entity for out-of-bounds ports.

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)`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API area:task-sdk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Connection port field does not validate that the value is a valid port number

1 participant