fix(proxied): stop reporting backend failures as "issue not found" (bd-3fs.2)

proxiedResolveIssueOrWisp returned (nil, false) and discarded the lookup
error, so its twelve callers could not tell a typo'd id from a dropped
connection - every failure printed "not found". It was the surviving
hand-rolled sibling of the proxiedGetIssueOrWisp that bd-hc1 deleted, and it
carried the same flaw in stronger form: bd-hc1's version at least returned
the error for the caller to ignore.

Delete it and route all twelve call sites through workapi.GetIssueOrWisp,
which already normalizes the domain seam's bare sql.ErrNoRows and the
nil-issue-with-nil-error pair onto storage.ErrNotFound. That leaves one
spelling of "resolve an id to issue-or-wisp" in cmd/bd rather than two, so
the discard cannot be reintroduced by writing the helper again.

Every not-found message is byte-unchanged - normalizing the sentinel must
not move what a user sees for a typo. Only the hard-error branch is new, and
it is the branch that was previously unreachable.

The twelve new cases in proxied_lookup_failure_test.go all fail against the
pre-fix code with "backend failure reported as a missing issue".

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
CI Bot 2026-08-01 05:13:54 +00:00
commit d793d435e1
11 changed files with 260 additions and 60 deletions

View file

@ -16,6 +16,7 @@ import (
"github.com/steveyegge/beads/internal/storage/uow"
"github.com/steveyegge/beads/internal/types"
"github.com/steveyegge/beads/internal/ui"
"github.com/steveyegge/beads/internal/workapi"
)
type closeProxiedInput struct {
@ -203,11 +204,15 @@ func gatherCloseProxiedInput(cmd *cobra.Command) closeProxiedInput {
}
func closeProxiedOne(ctx context.Context, uw uow.UnitOfWork, id, reason string, in closeProxiedInput, errs *[]string) (closeProxiedOutcome, bool) {
current, isWisp := proxiedResolveIssueOrWisp(ctx, uw, id)
if current == nil {
current, isWisp, err := workapi.GetIssueOrWisp(ctx, workapi.NewUOWDetailSource(uw), id)
if errors.Is(err, storage.ErrNotFound) {
*errs = append(*errs, fmt.Sprintf("Issue %s not found", id))
return closeProxiedOutcome{}, false
}
if err != nil {
*errs = append(*errs, fmt.Sprintf("Error resolving %s: %v", id, err))
return closeProxiedOutcome{}, false
}
if err := validateIssueClosable(id, current, actor, in.force); err != nil {
*errs = append(*errs, err.Error())
@ -216,13 +221,13 @@ func closeProxiedOne(ctx context.Context, uw uow.UnitOfWork, id, reason string,
if !in.force && current.IssueType == types.TypeEpic {
var openChildren int
var err error
var cerr error
if isWisp {
openChildren, err = uw.IssueUseCase().CountOpenWispChildren(ctx, id)
openChildren, cerr = uw.IssueUseCase().CountOpenWispChildren(ctx, id)
} else {
openChildren, err = uw.IssueUseCase().CountOpenChildren(ctx, id)
openChildren, cerr = uw.IssueUseCase().CountOpenChildren(ctx, id)
}
if err == nil && openChildren > 0 {
if cerr == nil && openChildren > 0 {
*errs = append(*errs, fmt.Sprintf("cannot close epic %s: %d open child issue(s); close children first or use --force to override", id, openChildren))
return closeProxiedOutcome{}, false
}
@ -236,10 +241,7 @@ func closeProxiedOne(ctx context.Context, uw uow.UnitOfWork, id, reason string,
}
params := domain.CloseIssueParams{Reason: reason, Session: in.session}
var (
res domain.CloseIssueResult
err error
)
var res domain.CloseIssueResult
// The is_blocked guard lives in the library's checked close, so the embedded
// and proxied paths converge on storage.ErrCloseBlocked and its message. The
// guard and the close share this unit-of-work transaction.
@ -287,18 +289,6 @@ func closeProxiedCommitMessage(outcomes []closeProxiedOutcome, claimed *types.Is
return msg
}
func proxiedResolveIssueOrWisp(ctx context.Context, uw uow.UnitOfWork, id string) (*types.Issue, bool) {
issue, err := uw.IssueUseCase().GetIssue(ctx, id)
if err == nil && issue != nil {
return issue, false
}
wisp, err := uw.IssueUseCase().GetWisp(ctx, id)
if err == nil && wisp != nil {
return wisp, true
}
return nil, false
}
func fireProxiedCloseHooks(ctx context.Context, before, after *types.Issue) error {
if after == nil {
return nil

View file

@ -164,10 +164,13 @@ func addCommentProxied(ctx context.Context, id, author, text string) (*types.Com
return nil, nil, HandleError("proxied-server UOW provider not initialized")
}
res, err := uow.RunTxResult(ctx, uowProvider, func(ctx context.Context, uw uow.UnitOfWork) (addCommentProxiedResult, string, error) {
issue, isWisp := proxiedResolveIssueOrWisp(ctx, uw, id)
if issue == nil {
issue, isWisp, rerr := workapi.GetIssueOrWisp(ctx, workapi.NewUOWDetailSource(uw), id)
if errors.Is(rerr, storage.ErrNotFound) {
return addCommentProxiedResult{}, "", fmt.Errorf("issue %s not found", id)
}
if rerr != nil {
return addCommentProxiedResult{}, "", fmt.Errorf("resolving %s: %w", id, rerr)
}
if err := validateIssueUpdatable(id, issue); err != nil {
return addCommentProxiedResult{}, "", err
}

View file

@ -2,13 +2,16 @@ package main
import (
"context"
"errors"
"fmt"
"os"
"time"
"github.com/steveyegge/beads/internal/storage"
"github.com/steveyegge/beads/internal/storage/uow"
"github.com/steveyegge/beads/internal/types"
"github.com/steveyegge/beads/internal/ui"
"github.com/steveyegge/beads/internal/workapi"
)
type deferProxiedResult struct {
@ -40,11 +43,15 @@ func runDeferProxiedServer(ctx context.Context, args []string, deferUntil *time.
res, err := uow.RunTxResult(ctx, uowProvider, func(ctx context.Context, uw uow.UnitOfWork) (deferProxiedResult, string, error) {
var r deferProxiedResult
for _, id := range args {
issue, isWisp := proxiedResolveIssueOrWisp(ctx, uw, id)
if issue == nil {
issue, isWisp, rerr := workapi.GetIssueOrWisp(ctx, workapi.NewUOWDetailSource(uw), id)
if errors.Is(rerr, storage.ErrNotFound) {
r.errs = append(r.errs, fmt.Sprintf("Error resolving %s: not found", id))
continue
}
if rerr != nil {
r.errs = append(r.errs, fmt.Sprintf("Error resolving %s: %v", id, rerr))
continue
}
fullID := issue.ID
updates := map[string]interface{}{
@ -108,11 +115,15 @@ func runUndeferProxiedServer(ctx context.Context, args []string) error {
res, err := uow.RunTxResult(ctx, uowProvider, func(ctx context.Context, uw uow.UnitOfWork) (deferProxiedResult, string, error) {
var r deferProxiedResult
for _, id := range args {
issue, isWisp := proxiedResolveIssueOrWisp(ctx, uw, id)
if issue == nil {
issue, isWisp, rerr := workapi.GetIssueOrWisp(ctx, workapi.NewUOWDetailSource(uw), id)
if errors.Is(rerr, storage.ErrNotFound) {
r.errs = append(r.errs, fmt.Sprintf("Error getting %s: not found", id))
continue
}
if rerr != nil {
r.errs = append(r.errs, fmt.Sprintf("Error getting %s: %v", id, rerr))
continue
}
fullID := issue.ID
if issue.Status != types.StatusDeferred {
r.errs = append(r.errs, fmt.Sprintf("%s is not deferred (status: %s)", fullID, string(issue.Status)))

View file

@ -45,10 +45,13 @@ func labelMutateProxied(ctx context.Context, args []string, operation string) er
err := uow.RunTx(ctx, uowProvider, func(ctx context.Context, uw uow.UnitOfWork) (string, error) {
resolvedIDs = resolvedIDs[:0]
for _, inputID := range issueIDs {
issue, isWisp := proxiedResolveIssueOrWisp(ctx, uw, inputID)
if issue == nil {
issue, isWisp, rerr := workapi.GetIssueOrWisp(ctx, workapi.NewUOWDetailSource(uw), inputID)
if errors.Is(rerr, storage.ErrNotFound) {
return "", fmt.Errorf("resolving issue ID %q: not found", inputID)
}
if rerr != nil {
return "", fmt.Errorf("resolving issue ID %q: %w", inputID, rerr)
}
for _, label := range labels {
var e error
switch {
@ -247,10 +250,13 @@ func runLabelPropagateProxiedServer(ctx context.Context, args []string) error {
parentID string
)
err := uow.RunTx(ctx, uowProvider, func(ctx context.Context, uw uow.UnitOfWork) (string, error) {
parent, _ := proxiedResolveIssueOrWisp(ctx, uw, args[0])
if parent == nil {
parent, _, rerr := workapi.GetIssueOrWisp(ctx, workapi.NewUOWDetailSource(uw), args[0])
if errors.Is(rerr, storage.ErrNotFound) {
return "", fmt.Errorf("resolving parent %q: not found", args[0])
}
if rerr != nil {
return "", fmt.Errorf("resolving parent %q: %w", args[0], rerr)
}
parentID = parent.ID
page, err := uw.IssueUseCase().SearchIssues(ctx, "", types.IssueFilter{ParentID: &parentID})

View file

@ -11,6 +11,7 @@ import (
"github.com/steveyegge/beads/internal/storage/domain"
"github.com/steveyegge/beads/internal/storage/uow"
"github.com/steveyegge/beads/internal/types"
"github.com/steveyegge/beads/internal/workapi"
)
type molReader interface {
@ -114,10 +115,13 @@ type uowMolReader struct {
}
func (r uowMolReader) GetIssue(ctx context.Context, id string) (*types.Issue, error) {
issue, isWisp := proxiedResolveIssueOrWisp(ctx, r.uw, id)
if issue == nil {
issue, isWisp, rerr := workapi.GetIssueOrWisp(ctx, workapi.NewUOWDetailSource(r.uw), id)
if errors.Is(rerr, storage.ErrNotFound) {
return nil, fmt.Errorf("issue %s not found", id)
}
if rerr != nil {
return nil, fmt.Errorf("resolving %s: %w", id, rerr)
}
var labels []string
var err error
if isWisp {

View file

@ -2,12 +2,15 @@ package main
import (
"context"
"errors"
"fmt"
"github.com/steveyegge/beads/internal/storage"
"github.com/steveyegge/beads/internal/storage/uow"
"github.com/steveyegge/beads/internal/types"
"github.com/steveyegge/beads/internal/ui"
"github.com/steveyegge/beads/internal/validation"
"github.com/steveyegge/beads/internal/workapi"
)
func proxiedMutateIssue(ctx context.Context, id, commitMsg string, mutate func(ctx context.Context, uw uow.UnitOfWork, issue *types.Issue, isWisp bool) error) (*types.Issue, error) {
@ -16,10 +19,13 @@ func proxiedMutateIssue(ctx context.Context, id, commitMsg string, mutate func(c
}
var updated *types.Issue
err := uow.RunTx(ctx, uowProvider, func(ctx context.Context, uw uow.UnitOfWork) (string, error) {
issue, isWisp := proxiedResolveIssueOrWisp(ctx, uw, id)
if issue == nil {
issue, isWisp, rerr := workapi.GetIssueOrWisp(ctx, workapi.NewUOWDetailSource(uw), id)
if errors.Is(rerr, storage.ErrNotFound) {
return "", fmt.Errorf("issue %s not found", id)
}
if rerr != nil {
return "", fmt.Errorf("resolving %s: %w", id, rerr)
}
if err := validateIssueUpdatable(id, issue); err != nil {
return "", err
}

View file

@ -69,12 +69,15 @@ func (p lookupOnlyProvider) Close(context.Context) error { return nil }
// otherwise with the domain seam's wrapped sql.ErrNoRows.
func withStubbedProxiedLookup(t *testing.T, hardErr error) {
t.Helper()
oldProvider, oldJSON := uowProvider, jsonOutput
oldProvider, oldJSON, oldWrote := uowProvider, jsonOutput, commandDidWrite.Load()
uowProvider = lookupOnlyProvider{issues: stubLookupIssueUC{hardErr: hardErr}}
jsonOutput = false
t.Cleanup(func() {
uowProvider = oldProvider
jsonOutput = oldJSON
// The mutating commands set commandDidWrite before they know whether
// anything resolved, and it drives the deferred Dolt commit in main.
commandDidWrite.Store(oldWrote)
})
}
@ -93,6 +96,27 @@ func showViewCmd(view string) *cobra.Command {
return cmd
}
// cmdWithStringFlag registers one string flag so the command under test does
// not fall back to an environment lookup for it - `bd comment add` shells out
// to git for the author when --author is empty, which has nothing to do with
// what is being tested here.
func cmdWithStringFlag(name, value string) *cobra.Command {
cmd := &cobra.Command{}
cmd.Flags().String(name, value, "")
return cmd
}
// closeReasonCmd registers the reason flags `bd close` reads before it resolves
// anything. collectCloseReasonFlags returns an error for an unregistered one,
// which would abort the command ahead of the lookup under test.
func closeReasonCmd() *cobra.Command {
cmd := &cobra.Command{}
for _, name := range []string{"resolution", "message", "comment"} {
cmd.Flags().String(name, "", "")
}
return cmd
}
// proxiedLookupCommands is every proxied-server call site that resolves an id
// through workapi.GetIssueOrWisp, driven at its real entry point with an id
// that cannot resolve. Each names the exact stderr line for the two ways that
@ -106,12 +130,16 @@ var proxiedLookupCommands = []struct {
// rows in result set", except gate list, which said "not found" for every
// failure including a dead backend.
wantNotFound string
// wantHardErr is stderr when the lookup fails for any other reason.
// wantHardErr is stderr when the lookup fails for any other reason. This is
// the half that used to be unreachable: gate list and every mutating
// command below it said "not found" for a dropped connection, a stale
// schema, anything at all.
wantHardErr string
// exitsZero marks the views that report per id and keep going. --refs and
// --children print the failure and move to the next id, so one bad id out
// of one still leaves the command at exit 0. That predates this slice; the
// branch under test is what they print, not what they return.
// exitsZero marks the commands that report per id and keep going. --refs,
// --children, defer, undefer and todo done print the failure and move to
// the next id, so one bad id out of one still leaves the command at exit 0.
// That predates these slices; the branch under test is what they print, not
// what they return.
exitsZero bool
}{
{
@ -190,13 +218,111 @@ var proxiedLookupCommands = []struct {
wantNotFound: "Error: message bd-missing not found",
wantHardErr: "Error: fetching message bd-missing: connection reset by peer",
},
// The mutating commands below reached the same seam through
// proxiedResolveIssueOrWisp, which returned a bare (nil, false) and so
// could only ever be read as "not found" (bd-3fs.2). Their wantNotFound
// lines are the ones they have always shipped; only wantHardErr is new.
{
name: "close",
run: func(ctx context.Context) error {
return runCloseProxiedServer(closeReasonCmd(), ctx, []string{stubMissingID})
},
wantNotFound: "Issue bd-missing not found",
wantHardErr: "Error resolving bd-missing: connection reset by peer",
},
{
name: "reopen",
run: func(ctx context.Context) error {
return runReopenProxiedServer(&cobra.Command{}, ctx, []string{stubMissingID})
},
wantNotFound: "Issue bd-missing not found",
wantHardErr: "Error resolving bd-missing: connection reset by peer",
},
{
name: "unclaim",
run: func(ctx context.Context) error {
return runUnclaimProxiedServer(ctx, []string{stubMissingID}, "", false)
},
wantNotFound: "Error resolving bd-missing: not found",
wantHardErr: "Error resolving bd-missing: connection reset by peer",
},
{
name: "defer",
run: func(ctx context.Context) error {
return runDeferProxiedServer(ctx, []string{stubMissingID}, nil, "")
},
wantNotFound: "Error resolving bd-missing: not found",
wantHardErr: "Error resolving bd-missing: connection reset by peer",
exitsZero: true,
},
{
name: "undefer",
run: func(ctx context.Context) error {
return runUndeferProxiedServer(ctx, []string{stubMissingID})
},
wantNotFound: "Error getting bd-missing: not found",
wantHardErr: "Error getting bd-missing: connection reset by peer",
exitsZero: true,
},
{
name: "label add",
run: func(ctx context.Context) error {
return runLabelAddProxiedServer(ctx, []string{stubMissingID, "urgent"})
},
wantNotFound: `Error: label added: resolving issue ID "bd-missing": not found`,
wantHardErr: `Error: label added: resolving issue ID "bd-missing": connection reset by peer`,
},
{
name: "label propagate",
run: func(ctx context.Context) error {
return runLabelPropagateProxiedServer(ctx, []string{stubMissingID, "urgent"})
},
wantNotFound: `Error: label propagate: resolving parent "bd-missing": not found`,
wantHardErr: `Error: label propagate: resolving parent "bd-missing": connection reset by peer`,
},
{
name: "set state",
run: func(ctx context.Context) error {
return runSetStateProxiedServer(ctx, stubMissingID, "phase", "done", "")
},
wantNotFound: "Error: issue bd-missing not found",
wantHardErr: "Error: resolving bd-missing: connection reset by peer",
},
{
name: "todo done",
run: func(ctx context.Context) error {
return runTodoDoneProxiedServer(&cobra.Command{}, ctx, []string{stubMissingID})
},
wantNotFound: "Error: failed to close bd-missing: issue bd-missing not found",
wantHardErr: "Error: failed to close bd-missing: resolving bd-missing: connection reset by peer",
exitsZero: true,
},
{
name: "assign",
run: func(ctx context.Context) error {
return runAssignProxiedServer(ctx, []string{stubMissingID, "someone"}, false)
},
wantNotFound: "Error: assign bd-missing: issue bd-missing not found",
wantHardErr: "Error: assign bd-missing: resolving bd-missing: connection reset by peer",
},
{
name: "comment add",
run: func(ctx context.Context) error {
return runCommentsAddProxiedServer(cmdWithStringFlag("author", "tester"), ctx, []string{stubMissingID, "hello"})
},
wantNotFound: "Error: issue bd-missing not found",
wantHardErr: "Error: resolving bd-missing: connection reset by peer",
},
}
// TestProxiedLookupReportsMissingIssue covers the errors.Is(storage.ErrNotFound)
// branch bd-hc1 added at every proxied call site. All but one used to hand the
// user db.issueSQLRepositoryImpl.Get's raw sql.ErrNoRows for a typo'd id; gate
// list is the exception, and its own regression is in
// TestProxiedLookupReportsBackendFailure.
// branch at every proxied call site. Of the read commands bd-hc1 migrated, all
// but one used to hand the user db.issueSQLRepositoryImpl.Get's raw
// sql.ErrNoRows for a typo'd id. The exceptions are gate list and the mutating
// commands, which already printed "not found" - for a miss and for a dead
// backend alike, which is what TestProxiedLookupReportsBackendFailure guards.
// Their lines here are unchanged, and that is the point: normalizing the
// sentinel must not move the message a user sees for a typo.
func TestProxiedLookupReportsMissingIssue(t *testing.T) {
for _, tc := range proxiedLookupCommands {
t.Run(tc.name, func(t *testing.T) {
@ -220,8 +346,11 @@ func TestProxiedLookupReportsMissingIssue(t *testing.T) {
// TestProxiedLookupReportsBackendFailure covers the other side of the same
// branch: a lookup that failed for a reason other than absence must say so.
// gate list is the regression this one guards - it answered "issue not found"
// for a dropped connection, a stale schema, anything at all.
// gate list is the regression bd-hc1 fixed here; every mutating command in the
// table is bd-3fs.2's. Those went through proxiedResolveIssueOrWisp, which
// returned a bare (nil, false) with the reason discarded, so "issue not found"
// was the only thing a caller could print - for a dropped connection, a stale
// schema, anything at all. Reverting any of those call sites fails this test.
func TestProxiedLookupReportsBackendFailure(t *testing.T) {
for _, tc := range proxiedLookupCommands {
t.Run(tc.name, func(t *testing.T) {
@ -264,3 +393,31 @@ func TestReportIssueLookupFailure(t *testing.T) {
}
})
}
// TestUOWMolReaderLookupFailure covers the twelfth caller of the deleted
// proxiedResolveIssueOrWisp. uowMolReader is a molReader adapter rather than a
// command, so it is driven directly: the molecule commands wrap whatever it
// returns, and what they must not be handed is "step not found" for a backend
// that never answered.
func TestUOWMolReaderLookupFailure(t *testing.T) {
newReader := func(hardErr error) uowMolReader {
return uowMolReader{uw: lookupOnlyUOW{issues: stubLookupIssueUC{hardErr: hardErr}}}
}
t.Run("absent id is not found", func(t *testing.T) {
_, err := newReader(nil).GetIssue(context.Background(), stubMissingID)
if got, want := fmt.Sprint(err), "issue bd-missing not found"; got != want {
t.Errorf("err = %q, want %q", got, want)
}
})
t.Run("backend failure keeps the reason", func(t *testing.T) {
_, err := newReader(errors.New(stubBackendError)).GetIssue(context.Background(), stubMissingID)
if got, want := fmt.Sprint(err), "resolving bd-missing: "+stubBackendError; got != want {
t.Errorf("err = %q, want %q", got, want)
}
if strings.Contains(strings.ToLower(fmt.Sprint(err)), "not found") {
t.Errorf("backend failure reported as a missing issue: %v", err)
}
})
}

View file

@ -2,6 +2,7 @@ package main
import (
"context"
"errors"
"fmt"
"os"
"strings"
@ -10,10 +11,12 @@ import (
"github.com/steveyegge/beads/internal/audit"
"github.com/steveyegge/beads/internal/hooks"
"github.com/steveyegge/beads/internal/storage"
"github.com/steveyegge/beads/internal/storage/domain"
"github.com/steveyegge/beads/internal/storage/uow"
"github.com/steveyegge/beads/internal/types"
"github.com/steveyegge/beads/internal/ui"
"github.com/steveyegge/beads/internal/workapi"
)
type reopenProxiedOutcome struct {
@ -100,14 +103,18 @@ func runReopenProxiedServer(cmd *cobra.Command, ctx context.Context, args []stri
return nil
}
func reopenProxiedOne(ctx context.Context, uw uow.UnitOfWork, id, reason string, errors *[]string) (reopenProxiedOutcome, bool) {
current, isWisp := proxiedResolveIssueOrWisp(ctx, uw, id)
if current == nil {
*errors = append(*errors, fmt.Sprintf("Issue %s not found", id))
func reopenProxiedOne(ctx context.Context, uw uow.UnitOfWork, id, reason string, errs *[]string) (reopenProxiedOutcome, bool) {
current, isWisp, rerr := workapi.GetIssueOrWisp(ctx, workapi.NewUOWDetailSource(uw), id)
if errors.Is(rerr, storage.ErrNotFound) {
*errs = append(*errs, fmt.Sprintf("Issue %s not found", id))
return reopenProxiedOutcome{}, false
}
if rerr != nil {
*errs = append(*errs, fmt.Sprintf("Error resolving %s: %v", id, rerr))
return reopenProxiedOutcome{}, false
}
if current.Status != types.StatusClosed {
*errors = append(*errors, fmt.Sprintf("%s is already %s", id, current.Status))
*errs = append(*errs, fmt.Sprintf("%s is already %s", id, current.Status))
return reopenProxiedOutcome{id: id, before: current, after: current, reopened: false}, true
}
@ -122,7 +129,7 @@ func reopenProxiedOne(ctx context.Context, uw uow.UnitOfWork, id, reason string,
res, err = uw.IssueUseCase().ReopenIssue(ctx, id, params, actor)
}
if err != nil {
*errors = append(*errors, fmt.Sprintf("Error reopening %s: %v", id, err))
*errs = append(*errs, fmt.Sprintf("Error reopening %s: %v", id, err))
return reopenProxiedOutcome{}, false
}

View file

@ -91,10 +91,13 @@ func runSetStateProxiedServer(ctx context.Context, issueID, dimension, newValue,
newLabel := dimension + ":" + newValue
res, err := uow.RunTxResult(ctx, uowProvider, func(ctx context.Context, uw uow.UnitOfWork) (setStateResult, string, error) {
issue, isWisp := proxiedResolveIssueOrWisp(ctx, uw, issueID)
if issue == nil {
issue, isWisp, rerr := workapi.GetIssueOrWisp(ctx, workapi.NewUOWDetailSource(uw), issueID)
if errors.Is(rerr, storage.ErrNotFound) {
return setStateResult{}, "", fmt.Errorf("issue %s not found", issueID)
}
if rerr != nil {
return setStateResult{}, "", fmt.Errorf("resolving %s: %w", issueID, rerr)
}
fullID := issue.ID
var labels []string

View file

@ -3,16 +3,19 @@ package main
import (
"context"
"encoding/json"
"errors"
"fmt"
"os"
"strings"
"github.com/spf13/cobra"
"github.com/steveyegge/beads/internal/storage"
"github.com/steveyegge/beads/internal/storage/domain"
"github.com/steveyegge/beads/internal/storage/uow"
"github.com/steveyegge/beads/internal/types"
"github.com/steveyegge/beads/internal/ui"
"github.com/steveyegge/beads/internal/workapi"
)
func todoListProxied(ctx context.Context, filter types.IssueFilter) ([]*types.Issue, error) {
@ -87,10 +90,13 @@ func runTodoDoneProxiedServer(cmd *cobra.Command, ctx context.Context, args []st
var closedIDs []string
for _, issueID := range args {
_, err := uow.RunTxResult(ctx, uowProvider, func(ctx context.Context, uw uow.UnitOfWork) (struct{}, string, error) {
issue, isWisp := proxiedResolveIssueOrWisp(ctx, uw, issueID)
if issue == nil {
issue, isWisp, rerr := workapi.GetIssueOrWisp(ctx, workapi.NewUOWDetailSource(uw), issueID)
if errors.Is(rerr, storage.ErrNotFound) {
return struct{}{}, "", fmt.Errorf("issue %s not found", issueID)
}
if rerr != nil {
return struct{}{}, "", fmt.Errorf("resolving %s: %w", issueID, rerr)
}
params := domain.CloseIssueParams{Reason: reason}
var e error
if isWisp {

View file

@ -2,14 +2,17 @@ package main
import (
"context"
"errors"
"fmt"
"os"
"strings"
"time"
"github.com/steveyegge/beads/internal/storage"
"github.com/steveyegge/beads/internal/storage/uow"
"github.com/steveyegge/beads/internal/types"
"github.com/steveyegge/beads/internal/ui"
"github.com/steveyegge/beads/internal/workapi"
)
type unclaimProxiedResult struct {
@ -26,11 +29,15 @@ func runUnclaimProxiedServer(ctx context.Context, args []string, reason string,
res, err := uow.RunTxResult(ctx, uowProvider, func(ctx context.Context, uw uow.UnitOfWork) (unclaimProxiedResult, string, error) {
var r unclaimProxiedResult
for _, id := range args {
issue, _ := proxiedResolveIssueOrWisp(ctx, uw, id)
if issue == nil {
issue, _, rerr := workapi.GetIssueOrWisp(ctx, workapi.NewUOWDetailSource(uw), id)
if errors.Is(rerr, storage.ErrNotFound) {
r.errs = append(r.errs, fmt.Sprintf("Error resolving %s: not found", id))
continue
}
if rerr != nil {
r.errs = append(r.errs, fmt.Sprintf("Error resolving %s: %v", id, rerr))
continue
}
fullID := issue.ID
if uerr := uw.IssueUseCase().Unclaim(ctx, fullID, actor, force); uerr != nil {