paritytech / paritytech/polkadot-cli

bug: audit --output json for stdout pollution in piped contexts

Open
#72 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
10
Forks
2
Avg merge
12h 35m
Merged PRs (30d)
4

Description

Problem

When piping polkadot-cli query ... --output json into jq or other JSON consumers, users have reported getting parse errors due to non-JSON output mixed into stdout. This makes the CLI unreliable in scripted/piped contexts.

Analysis

Code analysis shows printResult in src/core/output.ts produces valid JSON arrays. The Spinner is not used in the query path. The user may have hit this on an older version, but it's worth a thorough audit to prevent regressions.

Proposed Solution

Audit all stdout writes across all commands to ensure that when --output json is active, only printResult writes to stdout. Specifically:

  1. Grep for all console.log, process.stdout.write, and Bun.write(Bun.stdout, ...) calls
  2. Ensure spinner output, progress messages, and any informational text go to stderr when --output json is set
  3. Add a pipe-mode integration test that validates command --output json | jq . succeeds for representative queries

Priority

HIGH — this is the most annoying friction point reported by users.

Files to audit

  • src/core/output.ts
  • src/commands/query.ts
  • src/commands/inspect.ts
  • Any command file that writes to stdout

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading src/core/output.ts, src/commands/query.ts, and src/commands/inspect.ts, then grep the repository for console.log, process.stdout.write, and Bun.write(Bun.stdout, ...). Audit stdout behavior when --output json is active and add a pipe-mode integration test for representative queries. Done means JSON consumers such as jq receive only valid JSON, with informational output routed to stderr.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.