paritytech / paritytech/polkadot-cli
bug: audit --output json for stdout pollution in piped contexts
Nobody has claimed this yet.
- 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:
- Grep for all
console.log,process.stdout.write, andBun.write(Bun.stdout, ...)calls - Ensure spinner output, progress messages, and any informational text go to stderr when
--output jsonis set - 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.tssrc/commands/query.tssrc/commands/inspect.ts- Any command file that writes to stdout
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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