Skip to content

fix(dotfiles-secrets): EOF abort + bws ANSI-color JSON corruption - #37

Draft
yulonglin wants to merge 1 commit into
mainfrom
worktree-dotfiles-secrets-eof-fix
Draft

fix(dotfiles-secrets): EOF abort + bws ANSI-color JSON corruption#37
yulonglin wants to merge 1 commit into
mainfrom
worktree-dotfiles-secrets-eof-fix

Conversation

@yulonglin

Copy link
Copy Markdown
Owner

Summary

  • Fix dotfiles-secrets set: set -e treated read -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.
  • Fix bws JSON parsing: bws's --color auto misdetects color support even when piped into python3 -c 'json.load(sys.stdin)', wrapping the JSON in ANSI escape codes and breaking bws_project_id, bws_find_secrets, bws_list_full, and the secrets cache loader. Force --color no on every bws call whose output is parsed as JSON.

Test plan

  • bash -n custom_bins/dotfiles-secrets — syntax check passes
  • Seeded OBSIDIAN_AUTH_TOKEN, OBSIDIAN_ENCRYPTION_KEY, OBSIDIAN_ENCRYPTION_SALT end-to-end via dotfiles-secrets set KEY --note ... piped from local files
  • Verified all three via dotfiles-secrets keys
  • Verified byte-identical round-trip via dotfiles-secrets get-value vs. original files (cmp)

https://claude.ai/code/session_0139VmN3a8q2wzqc1AtYcoop

…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.
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