Skip to content

secrets env: retry a failed bws read, and show bws's whole error - #94

Merged
margani merged 1 commit into
mainfrom
fix/93-bws-retry
Oct 19, 2026
Merged

margani merged 1 commit into
mainfrom
fix/93-bws-retry

Conversation

@margani

@margani margani commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Closes #93.

What changed and why

In LytronHQ/nabz-internal, 3 of about 12 CI runs that read Bitwarden failed on the first attempt with bws could not read project … : Error:, and each rerun minutes later passed. The reason was hidden: bws prints Error: on its first line and the cause on the following ones, and action_env kept only head -1.

  • --attempts <n> (default 3) and --retry-wait <seconds> (default 3, doubled before each later try): a failed read is retried, and each retry is reported on stderr.
  • The final error carries bws's whole output on one line, capped at 600 characters.
  • fake-bws can fail its next N calls with a multi-line error shaped like the real one (Error: / blank / 0: Received error message from server: [429 …]).
  • README: the two flags.

How it was verified

  • bash secrets/tests/secrets_test.sh → PASS. New checks: two transient failures then success succeeds, after exactly 2 failed tries, and the retry is reported. A lasting failure stops after exactly 3 tries (--attempts default) and after 2 with --attempts 2, and the message contains 429 Too Many Requests from bws's third line. Bad values for both flags are refused.
  • Mutation tests. Restoring head -1: FAIL: … expected '429 Too Many Requests'. A single try: FAIL: two transient failures then success should succeed.
  • ./run-tests → all 10 passed, 3 skipped (the skips are Windows-only and the disposable-machine harden test).

Not verified

  • The real cause of the nabz failures. This change makes the next one show it, and retries let it recover. Whether it is Bitwarden's rate limit (the 429 in the fake is an assumption about its shape) will show in the first real failure's message.

A Bitwarden read failed transiently in about one CI run in four in
LytronHQ/nabz-internal; each rerun minutes later passed. The reason was
never visible: bws prints "Error:" on its first line and the cause on
the next ones, and action_env kept only head -1.

- --attempts <n> (default 3) and --retry-wait <seconds> (default 3,
  doubled before each later try) retry a failed read.
- The final error carries bws's whole output on one line, capped.
- fake-bws can fail its next N calls with a multi-line error like the
  real one; tests cover a transient failure recovering, a lasting one
  stopping after exactly --attempts tries with the reason shown, and bad
  values for both flags. Mutation-tested: head -1 and a single try both
  fail the suite.

Closes #93
@margani
margani merged commit c0a923b into main Oct 19, 2026
4 checks passed
@margani
margani deleted the fix/93-bws-retry branch October 19, 2026 15:17
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.

secrets env: retry a failed bws read, and show bws's whole error

1 participant