fix(dotfiles-secrets): EOF abort + bws ANSI-color JSON corruption - #37
Draft
yulonglin wants to merge 1 commit into
Draft
fix(dotfiles-secrets): EOF abort + bws ANSI-color JSON corruption#37yulonglin wants to merge 1 commit into
yulonglin wants to merge 1 commit into
Conversation
…uption `set -e` treated `read -rs`'s nonzero exit on EOF-without-trailing-newline (the common case for piped secret files) as fatal, aborting before the empty-value check ever ran, with no error printed. Separately, `bws`'s `--color auto` misdetects color support even when its stdout is piped to `python3 -c 'json.load(sys.stdin)'`, wrapping the JSON in ANSI escape codes and breaking every downstream parser (project lookup, secret lookup, list-full). Force `--color no` on all bws invocations whose output is parsed as JSON. Verified end-to-end by seeding OBSIDIAN_AUTH_TOKEN, OBSIDIAN_ENCRYPTION_KEY, OBSIDIAN_ENCRYPTION_SALT and confirming byte-identical round-trip via get-value.
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
dotfiles-secrets set:set -etreatedread -rs's nonzero exit on EOF-without-trailing-newline (the normal case when piping a secret file in) as fatal, silently aborting before the empty-value check ever ran, with no error message printed.bwsJSON parsing:bws's--color automisdetects color support even when piped intopython3 -c 'json.load(sys.stdin)', wrapping the JSON in ANSI escape codes and breakingbws_project_id,bws_find_secrets,bws_list_full, and the secrets cache loader. Force--color noon everybwscall whose output is parsed as JSON.Test plan
bash -n custom_bins/dotfiles-secrets— syntax check passesOBSIDIAN_AUTH_TOKEN,OBSIDIAN_ENCRYPTION_KEY,OBSIDIAN_ENCRYPTION_SALTend-to-end viadotfiles-secrets set KEY --note ...piped from local filesdotfiles-secrets keysdotfiles-secrets get-valuevs. original files (cmp)https://claude.ai/code/session_0139VmN3a8q2wzqc1AtYcoop