Skip to content

Structured-output commands print human progress text to stdout, breaking --format json | jq #1757

Description

@sneg55

Structured-output commands print human progress text to stdout, so --format json | jq fails on the leading prose

Context: API Makeathon participant. Found while reviewing the output handling of several commands.

Several commands write a human progress sentence to stdout before their structured output, so the complete stdout stream is no longer valid JSON or YAML when --format json is selected.

Evidence

  • File conversion writes wrote file... (src/cmd_file.rs:140-145) before the structured output (:158-160).
  • Text-to-CAD does the same (src/cmd_ml/cmd_text_to_cad.rs:125-159).
  • Project publish/upload do the same (src/cmd_project.rs:372-380 and :446-456).

src/cmd_org.rs:420-438 shows the correct pattern: it sends status text to stderr when structured output is selected.

Concrete failure

zoo file conversion ... --format json | jq . fails because the first line of stdout is the wrote file... sentence, not JSON. The same applies to the text-to-cad and project commands.

Verify

Drive each command with fixture responses, capture all stdout for --format json, and parse the full stream as JSON: parsing fails before reaching the serialized object.

Suggested fix

When a structured output format is selected, route progress and status text to stderr (as cmd_org.rs already does), keeping stdout a clean machine-readable stream.

Environment

Zoo CLI v0.2.184 (33534cd). Reviewed against the current main of KittyCAD/cli.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions