Commit graph

2 commits

Author SHA1 Message Date
Julian Knutsen
b2b153b7b8
fix(update): exit nonzero when a multi-ID update partially fails (#4726)
* fix(update): exit nonzero when a multi-ID update partially fails

bd update applies updates per issue ID, but the exit code only went
nonzero when every ID failed (len(args) > 0 && firstUpdatedID == "").
A single successful ID reset the whole batch to exit 0, so a bogus or
unresolvable ID mid-batch was silently swallowed and callers (scripts,
orchestrators) could not detect a partial batch. The GH audit flagged
this: per-ID errors were printed inline on stderr, but the process
reported success.

Empirical baseline-vs-patched evidence (red-team scenarios S1-S7):
baseline `bd update good1 bogus good2 --priority 1` exits rc=0 with one
inline stderr line; patched exits rc=1 with "1 of 3 issues failed to
update" plus a per-ID report. In --json mode the last stderr line is
now a machine-parseable failure report ({error, failed[], schema_version},
envelope-aware) while stdout keeps the array-of-updated-issues success
shape (parsed_list_len=2, both good IDs applied - the command stays
per-ID, not atomic). All-good paths are unchanged: rc=0 and stderr
byte-identical to baseline in both text and JSON modes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs: auto-regenerate CLI reference

Applied from the cli-docs-freshness-patch artifact of https://github.com/gastownhall/beads/actions/runs/29144979580
(generated with CI's canonical pinned build). See
scripts/check-cli-docs-drift.sh for how drift is attributed.

* docs: auto-regenerate CLI reference

Applied from the cli-docs-freshness-patch artifact of https://github.com/gastownhall/beads/actions/runs/29521598853
(generated with CI's canonical pinned build). See
scripts/check-cli-docs-drift.sh for how drift is attributed.

* fix(update): per-ID failure handling + output parity for multi-ID batches

Maintainer review fixup for PR #4726.

`bd update` over multiple IDs is per-ID, not atomic: every failed ID must
be reported and the command must exit nonzero while the other IDs still
update. Several paths still short-circuited that contract; this fixup
brings them all in line with the documented behavior.

Direct-mode metadata failures are now per-ID (review finding: major /
correctness). A `--metadata` merge or `--set-metadata`/`--unset-metadata`
edit that failed for one ID (e.g. that issue's stored metadata is not a
JSON object) used to return immediately -- aborting the batch, skipping
later IDs, and in --json mode writing the error to stdout instead of the
stderr failure report. It now prints the per-ID error, records the failed
ID, closes the unmutated result, and continues, exactly like the
resolve/update/label/parent paths. Added text and --json coverage with a
middle ID whose existing metadata is non-object for both the merge and the
edit paths.

Proxied-server exit-code parity (review finding: major / correctness). The
proxied path used to exit 0 whenever another ID in the batch succeeded,
hiding generic per-ID failures from exit-code automation.
runUpdateProxiedServer now accumulates every failed ID -- generic per-ID
errors and lost --claim races alike -- and returns the shared
reportUpdateFailures() after emitting successful output, so the batch
exits nonzero with the same stderr failure report (text and --json) as the
non-proxied path.

Proxied output-mode consistency (review finding: minor / maintainability).
Proxied success output now keys off the same global JSON decision (--json
OR --format json OR config) that reportUpdateFailures uses, so success
output and the failure report can no longer disagree on format within one
invocation.

Also fold the non-proxied reparent old-parent RemoveDependency failure
into the failed-ID ledger (review finding: minor / correctness): a failed
removal no longer proceeds to add the new parent edge on top of a stale
one, and no longer counts the ID as a silent success.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Test User <test@test.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
2026-07-18 19:34:20 -07:00
beads/crew/lizzy
10b1af3f9b test: add error case and missing command script tests (dolt-test-evu)
Add 12 new script tests covering error cases for existing commands
(create, update, show, close, dep, delete) and missing command
coverage (comments, label, search, config, lint, delete). All new
tests pass; 6 pre-existing script test failures remain unchanged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 18:47:41 -08:00