Skip to content

fix(cli)(sphere-sdk#282): route wallet use confirmation to STDERR#29

Merged
vrogojin merged 1 commit into
integration/all-fixesfrom
fix/issue-282-wallet-use-stderr
May 26, 2026
Merged

fix(cli)(sphere-sdk#282): route wallet use confirmation to STDERR#29
vrogojin merged 1 commit into
integration/all-fixesfrom
fix/issue-282-wallet-use-stderr

Conversation

@vrogojin
Copy link
Copy Markdown
Contributor

Summary

Companion to sphere-sdk PR #283. Residual #2 of the §D manual-test-full-recovery.sh ALL GREEN campaign — sphere wallet use <name> confirmation lines now go to STDERR so shell pipelines capturing the next command's stdout don't accidentally include the wallet-use banner.

Root cause

sphere wallet use alice printed

✓ Switched to wallet profile: alice
  Nametag:  alice-3862568c
  L1 Addr:  alpha1qxxt80l255l2h0jw3uy2sqwf86m6pg6jrvja42f

via console.log (stdout). The harness captures sphere balance > file snapshots; some snapshot blocks bracket wallet use outside the redirect (peer2: sphere wallet use alice ; sphere balance > file), others inside a subshell (peer1: ( … sphere wallet use alice && sphere balance ) > file). The two flows yield different captured-stdout content for the same logical operation, so the peer1-vs-peer2 diff failed despite identical balances.

Fix

Route the entire confirmation block (success and (wallet not initialized in this profile) fallback) through console.error. Errors (usage hint, profile-not-found) were already on stderr, so this brings the success path in line. Human operators in terminal sessions still see the banner; only > / | stdout pipelines are now unaffected.

Test plan

  • Updated test/integration/cli-wallet-profile.integration.test.ts — the existing wallet use alice assertion now expects the banner on r.stderr with a negative match on r.stdout.
  • npx vitest run --config vitest.integration.config.ts test/integration/cli-wallet-profile.integration.test.ts — 25/25 pass (including the updated assertion + the offline help-text and arg-validation pins).
  • npx vitest run (default unit suite) — 119/119 pass.
  • npm run build — clean.
  • npm run lint — no new errors.

Refs sphere-sdk#282

Residual #2 of the §D `manual-test-full-recovery.sh` ALL GREEN
campaign. The `sphere wallet use <name>` subcommand printed its
confirmation lines

  ✓ Switched to wallet profile: <name>
    Nametag:  <tag>
    L1 Addr:  <alpha1...>

via `console.log` (stdout). The harness captures `sphere balance >
file` snapshots; some snapshot blocks bracket the `wallet use`
invocation outside the redirect (peer2: `sphere wallet use alice ;
sphere balance > file`), others inside a subshell (peer1: `( …
sphere wallet use alice && sphere balance ) > file`). The two
flows yield different captured-stdout content for the same logical
operation, so the resulting peer1-vs-peer2 diff failed assertion
even though both wallets had identical balances.

Fix: route the entire confirmation block (success and `(wallet not
initialized in this profile)` fallback) through `console.error`.
Errors (usage hint, profile-not-found) were already on stderr, so
this brings the success path in line with them. Behaviour for human
operators is unchanged — terminal sessions still see the banner;
only `>` / `|` stdout pipelines are now unaffected by it.

Side-benefit: any future shell tooling that pipes
`sphere wallet use <name> | …` no longer has to filter the banner
out of the consumed stream.

Tests
  * `test/integration/cli-wallet-profile.integration.test.ts` —
    the "`wallet use alice` switches the active profile" assertion
    now expects the banner on `r.stderr` (with a negative match on
    `r.stdout`) per the new contract.
  * Full integration suite: 25 / 25 passed.
  * Full default unit suite: 119 / 119 passed.

Refs sphere-sdk#282
@vrogojin vrogojin merged commit 1278714 into integration/all-fixes May 26, 2026
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.

1 participant