Repository navigation
Stop kizen init printing the stored API key when it re-prompts - #73
Merged
Merged
Conversation
sangyeT
approved these changes
Oct 20, 2026
Rich shows a prompt's default even with password=True, which only hides what is typed. Re-running init on an existing profile therefore printed the stored key into scrollback, screen shares and recordings. Password prompts now pass show_default=False and say Enter keeps the stored key; bare Enter and an empty stdin still keep it.
jbedient-kizen
force-pushed
the
bug/init-prints-stored-api-key
branch
from
October 20, 2026 18:35
80edf38 to
6882d74
Compare
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.
Problem
Re-running
kizen initon an existing profile printed the stored API key in the prompt, asAPI_KEY (<key>):. Rich'spassword=Trueonly hides what is typed;show_defaultstill defaults toTrue, so the default (the stored key) was rendered. The key ended up in terminal scrollback, screen shares and recordings. With no stored profile the prompt showed an emptyAPI_KEY ():.Solution
_askincli/init.pypassesshow_default=not passwordto Rich, and when a password prompt has a stored value it adds the hint(Enter keeps the stored key), styled like Rich's own defaults. Bare Enter, and EOF on stdin, still return the stored key, so re-runninginitkeeps it without retyping. The fix sits in the one helper rather than at the call site, so any password prompt added later gets the same rule. Non-secret prompts (Profile name,BUSINESS_ID,USER_ID,Environment) still show their defaults.Testing
test_init_reprompt_hides_stored_api_key, run with bare Enter and with empty stdin: stores a profile with a fake key, re-runsiniton it, and asserts neither the key nor its last four characters appear in the output, the hint does,BUSINESS_ID (DDDD):still shows, and the profile still holds the key.test_init_api_key_prompt_has_no_empty_default: a new profile's prompt readsAPI_KEY:with no().init.py.2186 passed, 4 skipped, 90 deselected, 1 xfailed.XDG_CONFIG_HOMEand a fake key: a real pty, piped bare Enter (with and without-p),</dev/null, and failed credential checks (401 and connection refused, also withKIZEN_DEBUG=1). The key never appeared and stayed stored.Design notes / tradeoffs