Repository navigation
Suppress warning-stream ANSI output contaminating strongbox get's stdout - #20
Merged
Merged
Conversation
get/reveal --stdout are documented as piping-safe ("Print a secret's value to
stdout, for scripting/piping"). Discovered during real-world use (a deploy
script capturing `strongbox get POSTGRES_USER --real` via shell command
substitution) that PowerShell's warning stream writes ANSI-colored text
directly onto stdout in a non-interactive session (no real console attached -
invoked over SSH or from a shell script), rather than staying separate from
it. The module's own unapproved-verb warning on import was landing ahead of
the actual secret value in every capture, corrupting it (e.g. a captured
POSTGRES_USER became the literal ANSI escape fragment instead of the real
username, which then failed Postgres role lookup).
Set $WarningPreference = 'SilentlyContinue' for the whole CLI rather than
only suppressing the one known warning at import time, since any future
warning anywhere in this script's execution would hit the same
contamination.
Verified: 43/43 Pester tests still pass; confirmed on the actual Pi that
`strongbox get POSTGRES_USER --real` now returns exactly the expected bytes
with no leading escape sequence.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGra6GqN8qAxEDHbhmJwP2
2 tasks done
jpol34
added a commit
that referenced
this pull request
Sep 16, 2026
#21) Follow-up to #20: that fix set \$WarningPreference = 'SilentlyContinue' for every invocation, which also silences legitimate warnings for a human typing at a real terminal - the contamination bug it fixes only manifests when stdout is redirected (SSH, a shell script), not interactively. Moved Test-InteractiveTerminal earlier in the file (was only defined later, for Assert-RevealAllowed) and gated the suppression on it, matching the same interactive/non-interactive distinction --real already draws. Also reworded the comment to state the current invariant instead of narrating the bug's history, per doc-comment discipline. Verified: 43/43 Pester tests pass; confirmed on the Pi that `strongbox get POSTGRES_USER --real` still returns clean bytes non-interactively. Claude-Session: https://claude.ai/code/session_01WGra6GqN8qAxEDHbhmJwP2 Co-authored-by: jpol34 <jpol34@users.noreply.github.com> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test plan
🤖 Generated with Claude Code
https://claude.ai/code/session_01WGra6GqN8qAxEDHbhmJwP2