baptistegh opened a new issue, #77433:
URL: https://github.com/apache/airflow/issues/77433
### Airflow CTL Version
main (development)
### Airflow CTL Command
airflowctl pools list -o json
### Keyring Backend / Version
N/A
### Auth Type
None
### What is the current behaviour?
`airflowctl` prints every scalar as a string in `-o json` and `-o yaml`. For
example, `airflowctl pools list -o json` prints:
```json
[{"name": "default_pool", "slots": "128", "include_deferred": "False",
"description": null}]
```
The API returns `128` and `false`. User data is affected too: a Dag run
`conf` of `{"retries": 3, "dry_run": true}` is printed as `{"retries": "3",
"dry_run": "True"}`.
The conversion happens in `AirflowConsole._normalize_data`
(`airflow-ctl/src/airflowctl/ctl/console_formatting.py`), which calls
`str(value)` on every non-`None` scalar whatever the output format. Only
`table` and `plain` need text.
### What is the expected results?
`-o json` and `-o yaml` keep the JSON types returned by the API (`int`,
`float`, `bool`, `str`), so `jq '.[] | select(.slots > 10)'` or a YAML consumer
works without casting, and `"False"` (a truthy string) no longer appears in
scripts. `table` and `plain` keep rendering text.
### Anything else?
This may be intentional. The code was copied from the core CLI, whose
`_normalize_data` in `airflow-core/src/airflow/cli/simple_table.py` does the
same thing, so `airflow ... -o json` behaves the same way. The decision needed
from the airflowctl maintainers:
- Changing it is a behaviour change for anyone parsing the current string
output, so it needs a release note.
- `airflowctl` would no longer match the core `airflow` CLI output.
The change itself is small: keep `bool`/`int`/`float`/`str` as-is when
`output in ("json", "yaml")`.
Related: #77432. That PR fixes nested dicts being reshaped or losing keys in
the same output path, and leaves the string conversion as it is so the
behaviour change can be decided here.
### Are you willing to submit PR?
- [x] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
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]