Validate Connection port range; regenerate OpenAPI spec Fix/#70264#70426
Closed
bujjibabukatta wants to merge 2 commits into
Closed
Validate Connection port range; regenerate OpenAPI spec Fix/#70264#70426bujjibabukatta wants to merge 2 commits into
bujjibabukatta wants to merge 2 commits into
Conversation
bujjibabukatta
requested review from
bugraoz93,
choo121600,
ephraimbuddy,
henry3260,
jason810496,
pierrejeambrun,
rawwar and
shubhamraj-git
as code owners
July 25, 2026 03:42
shahar1
requested changes
Jul 25, 2026
shahar1
left a comment
Contributor
There was a problem hiding this comment.
Please fix PR's title (it should be indicative of what it fixes), fix failing CI checks, and add AI attribution to the PR's body
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.
What
The
portfield on the Connection REST API model (ConnectionBody) acceptedany integer, including negative numbers,
0, and values above65535.This adds a
ge=1, le=65535constraint so the API rejects out-of-rangeport numbers with a
422instead of silently persisting them, andregenerates the committed OpenAPI spec to match.
Why
A TCP/UDP port is only valid in the range 1-65535. Before this change,
POST /connectionsandPATCH /connectionswould happily accept thingslike
port: -1orport: 99999999, storing a value that no downstreamhook could actually connect with, and only surfacing as a confusing
runtime error much later.
How
airflow-core/src/airflow/api_fastapi/core_api/datamodels/connections.py— added
ge=1, le=65535to theportfield onConnectionBody. SinceConnectionTestRequestBodyand the PATCH partial model both derive fromConnectionBody, this covers create, update, and connection-test pathswith a single change.
airflow-core/src/airflow/api_fastapi/core_api/openapi/v2-rest-api-generated.yaml— regenerated to reflect the new
minimum/maximum/descriptiononportin bothConnectionBodyandConnectionTestRequestBody.Tests
test_post_should_respond_422_for_invalid_port— parametrized over[-1, 0, 65536, 99999, 123456789]test_post_should_respond_201_for_valid_port— parametrized over[1, 22, 8080, 65535]test_patch_should_respond_422_for_invalid_port— same invalid set via PATCHFull existing suite (145 tests) still passes;
ruff format/ruff checkclean on both changed Python files; regenerated OpenAPI spec validated
against the OpenAPI 3.1 schema.
Closes: #70264