Leondon9 opened a new issue, #62651:
URL: https://github.com/apache/airflow/issues/62651

   ### Apache Airflow version
   
   main (development)
   
   ### What happened?
   
   `airflowctl pools export` accepts `--output table|yaml|plain` via 
`ARG_OUTPUT` (defined in `cli_config.py:208-218`), but only the `json` format 
is properly handled. For all other formats, the command falls through to 
`rich.print(pools_list)` which outputs the raw Python list-of-dicts 
representation.
   
   The `AirflowConsole` class in `console_formatting.py` already provides 
proper formatting for all 4 output formats via its `print_as()` method, but 
`pool_command.py:export()` doesn't use it.
   
   ### What you think should happen instead?
   
   Non-json formats should produce properly formatted output:
   - `--output table` → rich table with columns (name, slots, description, ...)
   - `--output yaml` → YAML text
   - `--output plain` → plain tabulated output suitable for piping
   
   This is the behavior provided by `AirflowConsole().print_as()` and used by 
auto-generated list commands elsewhere in airflow-ctl.
   
   ### How to reproduce
   
   1. Start Airflow with at least one pool configured (the `default_pool` is 
always present)
   2. Run: `airflowctl pools export --output table pools.json`
   
   **Actual output:**
   ```
   [{'name': 'default_pool', 'slots': 128, 'description': 'Default pool', ...}]
   ```
   (Raw Python list repr via `rich.print()`)
   
   **Expected output:**
   A formatted table, similar to other `--output table` commands.
   
   The same issue occurs with `--output yaml` and `--output plain`.
   
   **Code reference** — 
`airflow-ctl/src/airflowctl/ctl/commands/pool_command.py:74-81`:
   ```python
   if args.output == "json":
       file_path = Path(args.file)
       with open(file_path, "w") as f:
           json.dump(pools_list, f, indent=4, sort_keys=True)
       rich.print(f"Exported {pools_response.total_entries} pool(s) to 
{args.file}")
   else:
       # For non-json formats, print the pools directly to console
       rich.print(pools_list)
   ```
   
   ### Operating System
   
   Linux
   
   ### Versions of Apache Airflow Providers
   
   N/A
   
   ### Deployment
   
   Other
   
   ### Deployment details
   
   Breeze development environment
   
   ### Anything else?
   
   _No response_
   
   ### 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]

Reply via email to