dajiaohuang opened a new pull request, #77460:
URL: https://github.com/apache/airflow/pull/77460

   A connection's `team_name` is what assigns it to a team. `airflowctl 
connections import`
   never read the field, so importing a team-scoped connection produced a 
connection with no
   team. It is worse than a field being left out: `ConnectionsOperations.bulk` 
serialises with a
   plain `model_dump()`, so the omitted field still travels as `"team_name": 
null`. The server's
   `handle_bulk_create` writes only fields the request actually provided
   (`exclude_unset=True`, added for exactly this reason), and an explicit null 
counts as
   provided — so `--action-on-existing-key overwrite` clears the team on a 
connection that had
   one and still reports success.
   
   `airflow connections export` writes `team_name` for every connection, so a 
backup already
   carries the value; only the airflowctl import side dropped it. This is the 
same root cause
   that #73132 fixed for pools, on the connection path it left in place.
   
   ### What
   
   `_build_connection_body` now reads `team_name` from the file entry, the same 
way `pools
   import` reads it after #73132. The field is `TeamName | None` on 
`ConnectionBody`, and
   `team_name` is a `Connection` constructor parameter, so it is also a legal 
key in a
   connections file for the core loader.
   
   `test_import_forwards_team_name` asserts on the serialised bulk body, so it 
pins what
   actually reaches the server rather than what the Pydantic model holds. The 
existing
   exact-kwargs assertion in `test_import_without_extra_field` gains the new 
constructor
   argument.
   
   ### Checks
   
   - `uv run --project airflow-ctl pytest 
airflow-ctl/tests/airflow_ctl/ctl/commands/test_connections_command.py -p 
no:timeouts` — 17 passed.
   - `test_import_forwards_team_name` fails on the unmodified base commit 
(`team_name` arrives as `None`) and passes with the change; verified by 
restoring the base blob with `git checkout`.
   - Full `airflow-ctl` suite, before and after, compared failure-for-failure: 
no regressions. The 31 pre-existing `test_client.py` failures in this 
environment are environmental (29 × `ssl.SSLError [SSL] unknown error` building 
an SSL context on this Windows host, 2 × `unreadable`-file tests relying on 
`chmod` permissions Windows does not enforce), as is 1 Windows regex-escape 
failure in `test_pool_command.py`. They fail identically on the untouched base.
   - `ruff format` / `ruff check` on both files: clean. `mypy` on the changed 
source: no issues.
   
   Note this does not address a hand-written file that omits `team_name` 
entirely; that still
   sends null. Changing what `bulk()` serialises shifts overwrite semantics for
   `description`/`include_deferred` as well and needs the same treatment in
   `variable_command`, so it is out of scope here.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes
   
   Generated-by: DeepSeek V4.1 Flash following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   


-- 
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]

Reply via email to