Skip to content

fix(cli): keep stdout valid JSON under --json (#546) - #553

Closed
tonylampada wants to merge 3 commits into
mainfrom
bc/SLM-101
Closed

tonylampada wants to merge 3 commits into
mainfrom
bc/SLM-101

Conversation

@tonylampada

@tonylampada tonylampada commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Fixes #546. Agents piping roboflow --json into jq break on search --export, image upload <dir>, model upload and version download, because SDK status lines land on stdout before the JSON. Under --json these SDK calls now print to stderr, so stdout is only the JSON document; text mode is unchanged. Serves objective O8 — one canonical API shape on every surface (CLI).

Note: #547 (external) takes the same approach; this one adds HTTP-level tests with responses. Merge whichever the maintainers prefer.

What changed

How has this change been tested?

Any specific deployment considerations

None.

Next step

Done for #546; a general "redirect stdout for the whole command under --json" would cover future handlers (deliberately out of scope).

PLAN
touches   CLI --json on search --export, image upload <dir>, model upload, version download → SDK prints move stdout→stderr; text mode unchanged
touches   model upload → workspace/project init now silenced (drops "loading Roboflow workspace...")
tests     each of 4 commands under --json: stdout parses with json.loads, SDK lines land on stderr · new tests/cli/test_json_stdout.py (HTTP mocked w/ responses, CliRunner)
tests     text mode keeps SDK lines on stdout · same file
review    CLAUDE.md "Agent experience: --json stable schema" — stdout must be only the JSON doc
review    CLAUDE.md "wrap SDK calls in suppress_sdk_output" — deliberate exception: per-image [ERR] lines (#545) stay visible on stderr
verify    python -m unittest tests.cli.test_json_stdout -v → 5 OK; fail on main for the 4 --json tests
verify    make check_code_quality → clean

🤖 Generated with Claude Code

tonylampada and others added 2 commits October 13, 2026 22:13
…ds (#546)

search --export, image upload <dir>, model upload and version download ran
SDK calls that print status lines to stdout, so --json output was not
parseable. In --json mode those calls now run with stdout redirected to
stderr (progress and per-image [ERR] lines stay visible); text mode is
unchanged. model upload also silences workspace/project init like the
other handlers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Newer ruff (unpinned in CI) flags these two imports, failing check_code_quality.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tonylampada

tonylampada commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator Author

Deliver checks (SLM-101)

  • Own review + verify recipe: python -m unittest tests.cli.test_json_stdout 5 OK; 4 --json tests fail on main; full suite 1234 OK; CI green
  • Evidence gist: https://gist.github.com/tonylampada/6b0d371853dbf289d23a2555746a519e
  • PR description per contract (<40 lines, objective O8, plan block)
  • Review round: /jarbas-review (ruling: no bot on this repo) — 1 fixed, 3 answered "won't fix, out of scope" (see comment below)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tonylampada

Copy link
Copy Markdown
Collaborator Author

Review round (jarbas-review), one pass:

@tonylampada

Copy link
Copy Markdown
Collaborator Author

Night-loop drill run; closed by Selma. #547 is the external fix for #546.

@tonylampada
tonylampada deleted the bc/SLM-101 branch October 14, 2026 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--json output is not valid JSON for search --export, image upload <dir>, model upload and version download

1 participant