Repository navigation
Description
Summary
lib/bitwarden-load-secrets.sh parses every value-taking option with an
unguarded "$2" + shift 2 (lines 44, 48, 81, 86, 90, 94: --item,
--field, --secret, --project, --prefix, --format). The script has
no set -u and no value check, so:
- A trailing value-option hangs forever. With
--itemas the last
argument,$#is 1,ITEM_QUERY="$2"reads empty, andshift 2fails
without advancing the positional parameters — thewhile [[ $# -gt 0 ]]
loop repeats the same iteration indefinitely. When the script is
sourced (its primary documented mode), this hangs the caller's shell. - A flag in the value position is swallowed as the value.
--item --bwssetsITEM_QUERY="--bws"and consumes the flag: the
script silently runs in vault mode against an item literally named
--bwsinstead of switching to Secrets Manager mode (or erroring).
This is the same missing/flag-like-value defect class fixed for the
aggregator scripts in #6926/#6922/#6930 and for record-claude-launch in
#6895, but here the failure mode is worse: an infinite loop instead of a
wrong record.
Evidence (verified this run, laptop main @4c3d00ccb7)
Probe: ~/git/fleet/probe-bw-load-args (real script verbatim, stub bw/bws
first on PATH, HOME pointed at an empty dir so the script's
~/.local/bin prepend cannot shadow the stubs):
- Control
--item StubItem --format json→ rc 0, prints
{"API_KEY": "sekrit"}from the stub item. bash lib/bitwarden-load-secrets.sh --item→ never returns; killed by
timeout 3(rc 124).bash lib/bitwarden-load-secrets.sh --item StubItem --format→ same
hang (rc 124).bash lib/bitwarden-load-secrets.sh --item --bws→ rc 0 in vault
mode, exporting the stub item's field (export API_KEY='sekrit'); the
--bwsflag was consumed as the item name and Secrets Manager mode
never engaged.
The existing contract suite scripts/tests/test_bitwarden_load_secrets.py
(4 tests, from #5650) covers multiline values only — no missing-value or
flag-as-value case.
Why it matters
This loader is sourced into shells to fetch credentials; a typo'd command
(source lib/bitwarden-load-secrets.sh --item) freezes the user's shell
with no message, and --item --bws-style slips silently query the wrong
backend/item instead of failing fast like every sibling script now does.
Acceptance criteria
- Each value-taking option (
--item,--field,--secret,--project,
--prefix,--format) with a missing, empty, or flag-like (--*)
value fails fast with a usage error naming the option — exit non-zero
when executed, and abort the source with non-zero status when sourced;
never loop. - Valid invocations are unchanged (all 4 existing tests in
scripts/tests/test_bitwarden_load_secrets.pystill pass). - New regression tests in that suite cover at least: trailing
--item,
trailing--format, and--item --bws(flag-as-value), each completing
under a timeout with a non-zero status and an error naming the option.
Activity
developing-today commentedon Nov 7, 2026
CODE-2182
dezren39 commentedon Nov 7, 2026
State: filed this run by new-issue-creator-code-b; taking the guarded self-solve path (trivial, clearly scoped, low-risk — the same guard pattern as #6926/#6922/#6930). Branch
creator-b/6932-bw-load-args-guardin a laptop worktree; fix + regression tests to follow, PR will reference this issue.Found via: filed this run — verified on laptop main @4c3d00ccb7 with probe ~/git/fleet/probe-bw-load-args (real script, stub bw/bws): trailing --item and trailing --format hang (timeout rc 124), --item --bws swallows the flag as the item name and runs in vault mode rc 0; control invocation rc 0 with correct output.
Merge pull request #6933 from developing-today/creator-b/6932-bw-load…
dezren39 commentedon Nov 7, 2026
Done: PR #6933 merged as def55ca. All six value-taking options now fail fast on a missing/empty/flag-like value; suite 8/8 on merged main (new tests fail/timeout pre-fix: 3 failures + 3 errors); probe re-run on merged main: trailing --item exits 1 naming the option, control invocation unchanged.
fix(lib): bitwarden-load-secrets validates value options before parsi…
Merge pull request #8161 from developing-today/daily/8158-bitwarden-g…