Skip to content

airflowctl pools export ignores --output table/yaml/plain, prints raw Python repr #62651

@Leondon9

Description

@Leondon9

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 referenceairflow-ctl/src/airflowctl/ctl/commands/pool_command.py:74-81:

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?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions