baptistegh opened a new pull request, #77432:
URL: https://github.com/apache/airflow/pull/77432
The generic printer behind auto-generated `airflowctl` commands changed the
shape of nested values in a response:
| API response | Before (`-o json`) | After |
|---|---|---|
| `{"dag_id": "d", "conf": {"foo": "bar"}}` | `"conf": "bar"` | `"conf":
{"foo": "bar"}` |
| `{"dag_id": "d", "conf": {"a": "1", "b": "2"}}` | `"conf": [{"a": "1",
"b": "2"}]` | `"conf": {"a": "1", "b": "2"}` |
| `{"dag_id": "d", "conf": {"total_entries": 3, "x": "1", "ids": ["a"]}}` |
`"conf": [{"x": "1", "ids": ["a"]}]` | `"conf": {"total_entries": 3, "x": "1",
"ids": ["a"]}` |
This affects every `dict` field in a response, such as Dag run `conf`,
`params` or asset `extra`.
Single-key unwrapping now applies only to the top-level response, and only
when the remaining key holds a list. That's the collection case (`{"dags":
[...], "total_entries": N}`). Collection responses and the one-row-per-tag
output from `dags get-tags` work as before. Paginated responses that also carry
`total_entries_limit`, `next_cursor` and `previous_cursor` (`dagrun list`,
`taskinstances list`) are still printed as one record, as on `main`. Unwrapping
them would hide the cursors needed to page, so that's left for a separate
change.
`test_nested_single_key_list_is_not_split_into_rows` (added in #73743) still
checks that the run is printed as one row. Its `conf` assertion pinned the
lossy shape `["a", "b"]`, so it now expects `{"ids": ["a", "b"]}`.
Scalars are still printed as strings in JSON and YAML. That behaviour comes
from the core Airflow CLI and is out of scope here.
**Question for reviewers:** a response with a single object is printed in
`-o json` and `-o yaml` as a list with one element. For example, `dagrun get`
prints `[{"dag_run_id": ...}]`. This happens because `print_as` takes a list of
rows for every format so that `table` and `plain` work. The PR keeps that shape
so the output stays the same as before for every `get` / `create` / `update`
command. Should single-object responses print as a bare object (`{...}`) in
JSON and YAML instead? That would break scripts that use `jq '.[0]'`, so I'd
rather do it in a follow-up if you want it.
Tested:
- `uv run --project airflow-ctl pytest airflow-ctl/tests`: 979 passed
- `prek run mypy-airflow-ctl`, `ruff` and `ruff-format` on the changed
files: passed
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes (please specify the tool below)
Generated-by: Claude Code (Opus 5.5) following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]