beads/cmd/bd/testdata
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
..
auto_export.txt fix(init): make JSONL auto-export opt-in (#4063) 2026-05-21 16:21:00 -07:00
blocked.txt Switch from hex to Base36 encoding for issue IDs (GH #213) 2025-11-03 12:02:15 -08:00
close.txt Switch from hex to Base36 encoding for issue IDs (GH #213) 2025-11-03 12:02:15 -08:00
close_errors.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
comments.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
config.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
create.txt Add scripttest-based integration tests (#59) 2025-10-16 17:11:54 -07:00
create_errors.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
delete.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
delete_errors.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
dep_add.txt fix: Update dep_add test to match current show output format 2025-11-04 00:23:25 -08:00
dep_errors.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
dep_remove.txt Switch from hex to Base36 encoding for issue IDs (GH #213) 2025-11-03 12:02:15 -08:00
dep_tree.txt Switch from hex to Base36 encoding for issue IDs (GH #213) 2025-11-03 12:02:15 -08:00
export.txt fix: remove nonexistent -i flag from bd import references (#3200) 2026-04-11 12:31:38 -07:00
formula_help.txt fix(docs-tooling): harden the CLI-docs pipeline per PR #4722 review 2026-07-12 11:07:12 -07:00
help.txt Add scripttest-based integration tests (#59) 2025-10-16 17:11:54 -07:00
import.txt fix: remove nonexistent -i flag from bd import references (#3200) 2026-04-11 12:31:38 -07:00
init.txt Fix config system: rename config.json → metadata.json, fix config.yaml loading 2025-11-02 14:31:22 -08:00
label.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
lint.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
list.txt Add scripttest-based integration tests (#59) 2025-10-16 17:11:54 -07:00
prime_content.txt feat: surface quality/lifecycle commands in prime, template, and doctor (fix-merge PR #2664) 2026-03-20 17:50:24 -07:00
quickstart.txt Add scripttest-based integration tests (#59) 2025-10-16 17:11:54 -07:00
ready.txt Add scripttest-based integration tests (#59) 2025-10-16 17:11:54 -07:00
search.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
show.txt Switch from hex to Base36 encoding for issue IDs (GH #213) 2025-11-03 12:02:15 -08:00
show_errors.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
stats.txt Switch from hex to Base36 encoding for issue IDs (GH #213) 2025-11-03 12:02:15 -08:00
update.txt docs(claim): standardize start-work semantics to --claim (#2070) 2026-02-24 22:11:39 -08:00
update_errors.txt fix(update): exit nonzero when a multi-ID update partially fails (#4726) 2026-07-18 19:34:20 -07:00
version.txt Add scripttest-based integration tests (#59) 2025-10-16 17:11:54 -07:00