algojogacor opened a new pull request, #68437: URL: https://github.com/apache/airflow/pull/68437
This is an independent contribution and is not associated with any hackathon or competition. ## Summary Add port validation to the `Connection.__init__` method to reject port values outside the valid TCP/UDP range (0-65535). ## Root Cause The `Connection` model accepted any integer value for the `port` field -- including negative numbers and values above 65535 -- with no validation. The invalid values were persisted to the database and later surfaced as confusing errors in downstream provider hooks, far from the source of the bad data. The port was set without validation in both the direct assignment path and the `_parse_from_uri` path. ## Fix A guard clause was added after both port assignment paths (direct and URI-parsed) that raises `AirflowException` when `port` is not None and falls outside 0-65535. This is consistent with the existing validation pattern used for `extra` in `_validate_extra`. ## Testing - Verified the file compiles with `python3 -m py_compile` - Existing test fixtures with valid ports (777, 1234) continue to pass unmodified - Invalid port values (e.g., -1, 99999) will now raise `AirflowException` at construction time Closes #68382 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
