fix: route wallet list summary to stderr, emit JSON on stdout - #576
fix: route wallet list summary to stderr, emit JSON on stdout#576erhnysr wants to merge 2 commits into
Conversation
The list handler printed its human-readable summary (names, EVM/Solana
addresses, default marker) to stdout via log(), so agents could not
JSON.parse the output. Route the summary to stderr and return a
structured { wallets } value so runCLI emits clean JSON on stdout,
matching how research commands emit their data. The empty case prints
its hint to stderr and still emits { "wallets": [] } on stdout.
pr-reviewer Summary for #e9d9814✅ No issues found The code review completed successfully with no findings. Review effort: 2/5 (Simple) SummaryThis PR correctly fixes Supporting changes are all correct:
Token usage: 2,429 input, 4,026 output, 402,589 cache read, 32,139 cache write | Usage Guide New pushes are reviewed automatically with a 10-minute cooldown between reviews. To request a review at any time, comment |
There was a problem hiding this comment.
Auto-approved
This PR was automatically approved because:
- Claude recommends approval
- Claude assessed this as a moderate effort change
- The effort level is within the auto-approval threshold of 2
- No high or critical issues were detected
- Review comment contains non-blocking feedback
If you have any concerns, please request a manual review.
|
Prior attempts at this same fix, both closed on the mistaken belief it had landed via #397:
I left a note on each explaining why #397 did not actually fix it (it only refactored the existence-check helper and never touched |
There was a problem hiding this comment.
Auto-approved
This PR was automatically approved because:
- Claude recommends approval
- Claude assessed this as a moderate effort change
- The effort level is within the auto-approval threshold of 2
- No high or critical issues were detected
If you have any concerns, please request a manual review.
The bug
nansen wallet listwrites its human-readable summary (wallet names, EVM/Solana addresses, the★default marker) to stdout vialog(), and returnsundefinedso no structured JSON is emitted. That mixes prose and data on the same stream, so agent pipelines that expect parseable output break:Every other data-returning command emits clean JSON on stdout;
wallet listis the odd one out, which makes it unusable in| jq-style automation.Prior history — why this keeps coming back
This was reported before in #289 and #406, and both were closed on the belief that the fix had already landed via #397. That belief is incorrect, and I verified it two ways before writing this:
requireWalletFile()helper for the file-existence checks inshowWallet,exportWallet,setDefaultWallet, anddeleteWallet(plus aderiveEvmAddress()helper intransfer.js). It is a self-described "no behavior changes" refactor and never toucheslistWalletsor thelisthandler.git log -L :listWallets:src/wallet.jstrace showslistWalletswas only ever touched by two commits: its original creation, and one Privy PR that added aproviderfield. No commit in its history ever introduced stderr/stdout separation.So this is a fresh fix, not a rebase or reopen of the older PRs — the output path they were meant to fix was never actually modified.
The fix
In the
listhandler (src/wallet.js):process.stderr.write(the file's existing convention).{ wallets }value sorunCLI's normal success path renders clean JSON to stdout — mirroring how research/data commands emit their output.No wallets foundhint to stderr and still returns{ wallets: [] }, so stdout is always valid JSON.After the fix:
(the summary still renders for humans — it's just on stderr now.)
Testing & verification
runCLI: before the fix it fails withSyntaxError: Unexpected end of JSON input(the summary went to real stdout, the JSON sink was empty) — reproducing the exact bug.npm run lint: clean.patch), user-facing.