Skip to content

Validate Connection port range; regenerate OpenAPI spec Fix/#70264#70426

Closed
bujjibabukatta wants to merge 2 commits into
apache:mainfrom
bujjibabukatta:fix/#70264
Closed

Validate Connection port range; regenerate OpenAPI spec Fix/#70264#70426
bujjibabukatta wants to merge 2 commits into
apache:mainfrom
bujjibabukatta:fix/#70264

Conversation

@bujjibabukatta

Copy link
Copy Markdown
Contributor

What

The port field on the Connection REST API model (ConnectionBody) accepted
any integer, including negative numbers, 0, and values above 65535.
This adds a ge=1, le=65535 constraint so the API rejects out-of-range
port numbers with a 422 instead of silently persisting them, and
regenerates the committed OpenAPI spec to match.

Why

A TCP/UDP port is only valid in the range 1-65535. Before this change,
POST /connections and PATCH /connections would happily accept things
like port: -1 or port: 99999999, storing a value that no downstream
hook 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=65535 to the port field on ConnectionBody. Since
    ConnectionTestRequestBody and the PATCH partial model both derive from
    ConnectionBody, this covers create, update, and connection-test paths
    with a single change.
  • airflow-core/src/airflow/api_fastapi/core_api/openapi/v2-rest-api-generated.yaml
    — regenerated to reflect the new minimum/maximum/description on
    port in both ConnectionBody and ConnectionTestRequestBody.

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 PATCH

Full existing suite (145 tests) still passes; ruff format / ruff check
clean on both changed Python files; regenerated OpenAPI spec validated
against the OpenAPI 3.1 schema.

Closes: #70264

@shahar1 shahar1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@bujjibabukatta bujjibabukatta changed the title Fix/#70264 Validate Connection port range; regenerate OpenAPI spec Fix/#70264 Jul 25, 2026
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants