* fix(show): explain that "not found" may mean deleted, not never-existed (ga-m6inyb) bd delete and wisp purge both remove a row (and its events) from the live tables with no trace left behind, so `bd show` on a deleted or purged id is byte-for-byte identical to one that never existed — confirmed live (Gas Town HQ Dolt server) against two real archived-wisp ids, and against dolt_history_wisps (always empty for wisps by design, per the dolt_ignore comments throughout internal/storage/dolt). An earlier draft of this fix tried to auto-detect the distinction via bd's own commit history (store.History), but that scan has a documented multi-second-to-timeout cost even on a healthy production database (reproduced live: `bd history` timed out with "row read wait bigger than connection timeout" on both a real archived wisp and a made-up id on the same server) — wiring it into show's default not-found path would regress the common typo case to fix a rarer one. Wisps never have history at all regardless, so it wouldn't have resolved the reported case either way. Instead, the not-found message now says plainly that the id may have existed and been removed, and points at `bd history <id>` as the (separate, opt-in) way to check further — additive only: the JSON "error" field text is unchanged, the new context lands in a "hint" field; the direct-mode text path keeps "Issue %s not found" as its first line and adds the hint as a second line. Also found, filed separately, not fixed here: `make ci-pr-lint` surfaces 2 pre-existing gosec findings in darwin/nonlinux-only files that the Linux CI runner never lints (no darwin cross-lint pass, unlike the existing Windows one) — confirmed present on a clean origin/main checkout, unrelated to this change. * fix(show): update contract-pinning tests for the new not-found hint (CI) CI on PR #5802 caught 4 test corpora this change needed to update but I missed locally (my earlier local run only matched tests named TestShow*; these pin the SAME code path — reportIssueLookupFailure and show.go's JSON not-found branch — under different names): - cmd/bd/proxied_lookup_failure_test.go: TestProxiedLookupReportsMissingIssue (show / show --refs / show --children / reopen rows) and TestReportIssueLookupFailure both assert exact stderr text by design ("Their lines here are unchanged, and that is the point" — the file's own doc comment). Updated the 4 affected wantNotFound values to include the new hint, computed via showNotFoundHint() rather than duplicated as a literal, so the two can't drift independently. - cmd/bd/protocol/testdata/corpus/{flat,envelope}/error.json and their manifest.json SHA-256 entries: the committed golden-file corpus for `bd show <missing> --json`. `make corpus-regen` needs Docker (unavailable here) to regenerate for real, so I independently reimplemented corpus.go's exact marshalCanonical encoding (same json.Encoder settings: SetEscapeHTML(false), 2-space indent) in a standalone program and confirmed both edited files are byte-for-byte identical to what that encoder produces, before hand-computing and writing the new SHA-256 manifest entries. Two more matches from a repo-wide grep for the old exact string (linear_test.go, update_claim_proxied_test.go) needed no change: linear_test.go's is an unrelated subsystem's own literal message, and update_claim_proxied_test.go asserts via strings.Contains, which the purely-additive hint doesn't break. Local verification (same commands as before, still Docker-less): go build ./..., go vet ./cmd/bd/..., go vet -tags=integration, make ci-pr-lint (2 pre-existing unrelated darwin-only gosec findings only), and the full previously-failing test names plus a broader NotFound| LookupFailure|Claim sweep — all green. * docs(changelog): add [Unreleased] entry for the show not-found hint (ga-m6inyb) Addresses reviewer bee-ghosttrack's second ask on PR #5802: "this adds a line to one of bd's most common outputs and a new JSON field" needs a CHANGELOG entry. Filed under Fixed, since the underlying bead is a bug (archived and never-existed issues were indistinguishable via bd show). Also documents, per the reviewer's first ask, that the direct-mode single-ID not-found path's first line is not purely additive: it changes from "Error fetching <id>: ..." to "Issue <id> not found" to match the wording the other not-found paths already used. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> Co-authored-by: Steve Yegge <steve.yegge@gmail.com>
36 lines
1.3 KiB
Go
36 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// TestShowNotFoundHint_PointsAtHistoryAndAcknowledgesDeletion guards
|
|
// ga-m6inyb: bd show's "not found" message must stop implying an ID never
|
|
// existed (it may have existed and been deleted/purged, which leaves no
|
|
// trace in the live tables) and must tell the reader how to check further.
|
|
func TestShowNotFoundHint_PointsAtHistoryAndAcknowledgesDeletion(t *testing.T) {
|
|
hint := showNotFoundHint("bd-1234")
|
|
|
|
if !strings.Contains(hint, "bd history bd-1234") {
|
|
t.Errorf("expected hint to name the exact id in a 'bd history' pointer, got: %q", hint)
|
|
}
|
|
if !strings.Contains(hint, "deleted") && !strings.Contains(hint, "purged") {
|
|
t.Errorf("expected hint to acknowledge deletion/purge as a possibility, got: %q", hint)
|
|
}
|
|
if !strings.Contains(hint, "never existed") {
|
|
t.Errorf("expected hint to name 'never existed' as only ONE of the possibilities, got: %q", hint)
|
|
}
|
|
}
|
|
|
|
func TestShowNotFoundHint_IsIDSpecific(t *testing.T) {
|
|
a := showNotFoundHint("bd-aaa")
|
|
b := showNotFoundHint("bd-bbb")
|
|
|
|
if a == b {
|
|
t.Errorf("expected hint text to vary with id, got identical output: %q", a)
|
|
}
|
|
if !strings.Contains(a, "bd-aaa") || strings.Contains(a, "bd-bbb") {
|
|
t.Errorf("expected hint for bd-aaa to reference only its own id, got: %q", a)
|
|
}
|
|
}
|