Skip to content

fix(cli): eight commands name csv in --format help and refuse it #4943

Open

Description

@dan-petty

Problem Description

Eight commands say in the help of --format that they accept csv, but each one refuses it. The help text is the literal Output format (table, json, yaml, csv): seven uses in src/devops_cli/commands/tf.py and one in src/devops_cli/commands/status_cmd.py. normalize_format in src/devops_cli/output/serialization.py accepts only the names of CONST_OUTPUT_FORMATS: json, table and yaml.

Reproduction Steps

  1. Run uv run devops tf notify-plan --format csv.

Expected vs Actual Behavior

Expected: the help of --format names only the formats that the command accepts, so the help and the refusal agree.

Actual: the help names csv, and the command fails with Unknown output format 'csv'. Choose one of: json, table, yaml.

Environment Diagnostics

devops-cli at origin/main, 2026-11-12.

Logs, Traces, or Terminal Output

$ devops tf notify-plan --pr 42 --format csv
✗ Unknown output format 'csv'. Choose one of: json, table, yaml.

Existing tool considered

None. The help of these options can read the names from CONST_OUTPUT_FORMATS, or use the shared help text of the other commands.

Related

Related: #3644, which found it.

Alternatives check of 2026-11-21: in-use.
The repository already uses this tool.
Tool: fastapi/typer (https://github.com/fastapi/typer), MIT, last activity 2026-11-18, maintained.
Reason: Web searches surfaced no separate tool; Typer, the CLI framework the issue already names, renders an enum option as a choice list, refuses other values with exit 2, and records the usage error.

Covers:

  • Enum option lists accepted values in --help
  • Wrong value becomes a usage error with exit 2
  • StrEnum member stays a str for resolve_format

Lacks:

  • No yml alias and no case-insensitive match
  • No shared CONST_OUTPUT_FORMATS value set
  • No regeneration of the generated CLI docs

Proposed design

Problem statement

Eight commands name csv in the help of --format and refuse it with Unknown output format. The same shared help text also names markdown for commands that refuse it, and all 155 --format options are a plain str today. The help and the refusal come from two different places. The fix gives every --format option a Typer enum of the values that its command accepts, so the help names only accepted values and a wrong value exits 2.

Acceptance criteria

Requirement: Shared serialization format enum

The CLI MUST define the serialization output formats once as a StrEnum whose values are json, table, yaml and yml.

Scenario: The enum holds the constant values and the yml alias

  • WHEN A test imports the shared output-format enum from src/devops_cli/output/serialization.py
  • THEN Its values are json, table, yaml and yml, and their set equals CONST_OUTPUT_FORMATS | {'yml'}.

Requirement: Every format option is a choice

Every --format option of the CLI MUST take a Typer enum whose choices are the formats that its command accepts, not a plain str.

Scenario: No format option stays a plain string

  • WHEN A test walks every command of the root Typer app and finds each --format parameter
  • THEN Each --format parameter has a parameter type with a non-empty choices tuple, and no --format option help holds csv.

Requirement: Eight commands name no csv

The eight commands that the issue names SHALL show only accepted values in the help of --format.

Scenario: The help of tf notify-plan and of status names no csv

  • WHEN A test runs CliRunner on devops tf notify-plan --help and on devops status --help
  • THEN The output holds [json|table|yaml|yml] and holds no csv.

Requirement: A wrong value exits 2

A --format value outside the choices MUST exit 2 with the accepted values in the message.

Scenario: csv is a usage error

  • WHEN A test runs CliRunner on devops tf notify-plan --plan-file with a temporary plan file and --format csv
  • THEN The exit code is 2, the message holds the accepted values, and no Unknown output format text appears.

Requirement: No exit-1 format refusal

A wrong --format value MUST NOT reach normalize_format, so no command exits 1 with Unknown output format or Unsupported format.

Scenario: The usage error replaces the exit-1 refusal

  • WHEN A test runs CliRunner on devops gh rate-limit --format jsno and on devops tf lint --format csv
  • THEN Each exit code is 2, and the output holds no Unsupported format and no Unknown output format.

Requirement: The accepted values stay

normalize_format MUST still accept every value that it accepts today.

Scenario: The yml alias and the case-insensitive match stay

  • WHEN A test calls normalize_format('YML') and normalize_format('csv')
  • THEN The first call returns yaml and the second call raises ValidationError with the accepted names.

Requirement: A format value keeps its case-insensitive match

A --format option that takes the shared serialization enum MUST accept a value in any case.

Scenario: An upper-case value is accepted

  • WHEN A test runs CliRunner on devops tf lint --format JSON --dry-run
  • THEN The exit code is 0 and the output is JSON.

Requirement: The generated CLI docs are regenerated

The pull request that changes the --format help MUST regenerate the generated CLI docs, docs/CLI_REFERENCE.md, docs/commands/*.md and docs/MCP_TOOLS.md.

Scenario: The docs check reports no stale document

  • WHEN uv run devops ci --check --only docs runs
  • THEN It exits 0 and reports no stale generated document.

Existing Tool Considered

The alternatives check of 2026-11-15 found no separate external tool, but the project's CLI framework Typer 0.28.0 and its Click 8.5.1 (pyproject.toml:12-13) already cover the need: a Typer enum option renders as choice (completed|not-planned) in the docs (docs/commands/gh.md:649), refuses another value with exit 2, and the root group records it as bad_value. The project already uses IssueCloseReason(StrEnum) as an option type (src/devops_cli/commands/gh.py:1386 and :1411). The library lacks the project's yml alias and its CONST_OUTPUT_FORMATS list, which a small StrEnum in src/devops_cli/output/serialization.py supplies, and it does not regenerate docs/CLI_REFERENCE.md, docs/commands/*.md or docs/MCP_TOOLS.md, which uv run devops docs generate does. Cost: about 20 lines of enum definitions and one option-type edit in each command module, about 15k tokens to build, keep and fix, and 4 to 6 hours.

Key questions

  • Which output formats does the CLI accept today?: CONST_OUTPUT_FORMATS at src/devops_cli/config/constants.py:4795 holds json, table and yaml. normalize_format at src/devops_cli/output/serialization.py:26 lowercases the value, maps yml to yaml, and raises ValidationError for every other value. Commands that use other formats have their own checks, such as table/json at src/devops_cli/commands/gh.py:1577 and text/markdown/json at src/devops_cli/commands/ai.py:1795. [sources: src/devops_cli/config/constants.py:4795, src/devops_cli/output/serialization.py:26, src/devops_cli/commands/gh.py:1577, src/devops_cli/commands/ai.py:1795]
  • Where does the help text that names csv come from?: The literal Output format (table, json, yaml, csv) is the help of seven --format options in src/devops_cli/commands/tf.py (lines 300, 475, 581, 764, 854, 917 and 981) and of one in src/devops_cli/commands/status_cmd.py (line 109). Each of these commands calls resolve_format and refuses csv. [sources: src/devops_cli/commands/tf.py:300, src/devops_cli/commands/tf.py:475, src/devops_cli/commands/tf.py:581, src/devops_cli/commands/tf.py:764, src/devops_cli/commands/tf.py:854, src/devops_cli/commands/tf.py:917, src/devops_cli/commands/tf.py:981, src/devops_cli/commands/status_cmd.py:109]
  • How should each --format option declare the values that it accepts?: Each --format option takes a Typer StrEnum whose members are the formats that its command accepts. The project already does this: IssueCloseReason(StrEnum) at src/devops_cli/commands/gh.py:1386 is the type of --reason at :1411, and docs/commands/gh.md:649 shows the help as choice (completed|not-planned). The archived design records that Typer refuses another value with exit 2 and Click's message (openspec/changes/archive/2026-10-29-1658-issues-close-reason/design.md:23). A StrEnum member is a str, so resolve_format keeps its signature. A single shared click.Choice from CONST_OUTPUT_FORMATS would refuse values that other commands accept today, such as markdown, text, dot and prometheus, and Typer 0.28 vendors Click as typer._click (src/devops_cli/core/cli.py:14), so a top-level click.Choice is not the type that a Typer option takes. (best practice) [sources: src/devops_cli/commands/gh.py:1386, src/devops_cli/commands/gh.py:1411, docs/commands/gh.md:649, openspec/changes/archive/2026-10-29-1658-issues-close-reason/design.md:23, pyproject.toml:13, src/devops_cli/core/cli.py:14, src/devops_cli/commands/ai.py:1795, src/devops_cli/commands/ai_gateway.py:103, src/devops_cli/commands/k8s/cluster_context.py:416, src/devops_cli/commands/ai_ast.py:106, docs/MCP_TOOLS.md:273]
    • Chosen: A Typer StrEnum for each accepted value set. The project already uses IssueCloseReason(StrEnum) as an option type, and Typer renders it as a choice, refuses another value with exit 2, and the root group records bad_value; a StrEnum member is a str, so resolve_format keeps its signature.
    • Rejected: One shared click.Choice from CONST_OUTPUT_FORMATS. The commands accept markdown, text, dot and prometheus as well, and Typer 0.28 vendors Click as typer._click, so a top-level click.Choice is not the type that a Typer option takes.
    • Rejected: A help text from the constant only. The help and the refusal stay two sources, and a wrong value still exits 1 with no usage error.
  • Should the shared format type keep the yml alias and the case-insensitive match?: Yes. normalize_format lowercases the value and maps yml to yaml today, so the serialization enum has a YML member and each option that takes it accepts a value in any case. A list of the three constant names alone would refuse --format JSON and --format yml, which the CLI accepts today. (best practice) [sources: src/devops_cli/output/serialization.py:26, src/devops_cli/output/serialization.py:32]
    • Chosen: Keep the yml alias and the case-insensitive match. It keeps every value that normalize_format accepts today, YML and yml included.
    • Rejected: Use the exact names of CONST_OUTPUT_FORMATS. It refuses --format JSON and --format yml, which work today.
  • How does a wrong --format value reach the usage-error record?: Click's choice conversion raises BadParameter, a UsageError. The root UsageRecordingGroup wraps make_context and invoke in _recorded_usage_errors (src/devops_cli/core/cli.py:201), which calls record_usage_error for each UsageError (src/devops_cli/core/cli.py:217). _classified maps BadParameter to UsageErrorKind.BAD_VALUE (src/devops_cli/telemetry/usage_errors.py:186), so the ledger gets one bad_value record with the option name. The change adds no recording code. [sources: src/devops_cli/core/cli.py:201, src/devops_cli/core/cli.py:217, src/devops_cli/telemetry/usage_errors.py:186, tests/telemetry/test_usage_errors.py:87]
  • How does the project keep the generated CLI docs correct?: docs/CLI_REFERENCE.md, docs/commands/*.md and docs/MCP_TOOLS.md are generated documents. uv run devops docs generate writes them, and the docs row of Static Analysis runs uv run devops ci --check --only docs and refuses a document that is not the output of its generator (CONTEXT.md:245, docs/ROUTINE_TASKS.md:33). [sources: CONTEXT.md:245, docs/ROUTINE_TASKS.md:33]
  • Does one pull request deliver the change?: Yes. The change is one enum per accepted value set, one edit per --format option and the regenerated docs. It is mechanical, and no part waits on another item. (best practice) [sources: src/devops_cli/output/serialization.py, docs/CLI_REFERENCE.md]
    • Chosen: One pull request. The reply of 2026-11-13 asks for the docs regeneration in the same pull request, and the edit is mechanical.
    • Rejected: Split by command group. It repeats the shared enums and leaves the help inconsistent between the groups.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/cli
    status/new
    value/low
    effort/low
    on Nov 12, 2026
  2. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/cli. The (cli) scope of the title gives the scope.
    • Priority: P3-Low. Help text inconsistency causes confusion but no functional failure.
    • Value: Low. Corrects misleading help text without changing command behaviour.
    • Effort: Low. Edit help strings in two files to remove csv.
    • Related: feat(cli): output format adoption across the command surface #411, which asks for a different change. Both concern output formats in the CLI, but #411 adds format support while this fixes help text that names an unsupported format.
  3. added
    priority/p3-low
    on Nov 12, 2026
  4. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    New evidence of 2026-11-13 (review of failing CLI calls). I propose to fix the cause, not the help text.

    • Tree walk of release 0.129.1: all 155 --format options are a plain str, and the help shows <str> with no value names.
    • normalize_format (src/devops_cli/output/serialization.py, near lines 26-40), src/devops_cli/commands/gh.py (near lines 1576-1577) and src/devops_cli/commands/pr.py (near line 653) refuse a wrong value with exit 1. For example, devops gh rate-limit --format jsno exits 1 and makes no usage-error record. So nobody can count wrong values today.
    • 98 of 495 leaf commands have both a true/false --json and --format json.

    Scope point: each --format option uses one shared click.Choice (or a Typer Enum) with the formats that the command supports. Then:

    • the help names the values,
    • a wrong value exits 2 with a close-match hint,
    • the root group records it as a bad_value usage error,
    • the hand checks go.

    Regenerate docs/CLI_REFERENCE.md in the same pull request, because the help of 155 options changes.

    Measure: cli_usage_error records of kind bad_value for --format appear, and exit-1 "Unsupported format" errors go to 0.

  5. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: The searches for CLI option-choice/help tooling returned no relevant tool or library: the results were unrelated general pages, and nothing found addresses a project-internal help-string bug. The need is to make the --format help in src/devops_cli/commands/tf.py and status_cmd.py name only the formats that normalize_format/CONST_OUTPUT_FORMATS accept, which is an edit of the project's own code (or reuse of the project's existing option types), not something an external tool covers.

    Tool: none found

    Lacks:

    • No external tool rewrites the misleading --format help text in the project's own commands
    • No external tool reconciles the help with CONST_OUTPUT_FORMATS / normalize_format
    • The bad_value usage-error recording and CLI reference regeneration are project-specific work

    Searches run:

    • Typer Enum option type help names accepted values invalid value usage error, results: 5
    • click.Choice option shows choices in help text and rejects invalid value with exit code 2, results: 5
    • "click.Choice" typer CLI validate option values github, results: 5
    • Click Python command line library Choice type documentation choices help, results: 5
    • pallets click documentation options choice parameter type, results: 5
    • CLI framework enumerate allowed values of an option in help text and reject other values, results: 5

    Checked on 2026-11-15. A person decides what this means for the item. The check changes no label and closes no issue.

  6. added
    status/ready
    and removed
    status/new
    on Nov 19, 2026
  7. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  8. devops-cli-service commented on Nov 21, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: none, no tool. A person decides what the new result means for the item.

    Searches (4)

    Tools considered:

    Searches run:

    • Typer CLI enum option choices validate invalid value exit code 2, results: 5
    • python typer Enum option shows accepted values in --help click Choice BadParameter, results: 5
    • typer tiangolo tutorial parameter types enum, results: 5
    • Click python command line library Choice type usage error invalid value, results: 5

    Sources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p3-lowscope/clisource/agentstatus/readytype/bugvalue/low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions