From 3197193e42ebfe9bf20fde3072b638739721f1ed Mon Sep 17 00:00:00 2001 From: Kynan Ware <47394200+BagToad@users.noreply.github.com> Date: Fri, 29 Aug 2025 19:13:35 -0600 Subject: [PATCH] Handle repo resolution errors gracefully in agent-task list Updated listRun to ignore errors from BaseRepo resolution and proceed when possible. Adjusted tests to reflect that repo resolution errors no longer surface, improving robustness when repo information is ambiguous. --- pkg/cmd/agent-task/list/list.go | 10 ++++++---- pkg/cmd/agent-task/list/list_test.go | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pkg/cmd/agent-task/list/list.go b/pkg/cmd/agent-task/list/list.go index 64c9e7d33..e6cd4e557 100644 --- a/pkg/cmd/agent-task/list/list.go +++ b/pkg/cmd/agent-task/list/list.go @@ -85,11 +85,13 @@ func listRun(opts *ListOptions) error { defer opts.IO.StopProgressIndicator() var sessions []*capi.Session ctx := context.Background() + + var repo ghrepo.Interface if opts.BaseRepo != nil { - repo, err := opts.BaseRepo() - if err != nil { - return err - } + repo, _ = opts.BaseRepo() + } + + if repo != nil && repo.RepoOwner() != "" && repo.RepoName() != "" { sessions, err = capiClient.ListSessionsForRepo(ctx, repo.RepoOwner(), repo.RepoName(), opts.Limit) if err != nil { return err diff --git a/pkg/cmd/agent-task/list/list_test.go b/pkg/cmd/agent-task/list/list_test.go index a653d51be..8b809f880 100644 --- a/pkg/cmd/agent-task/list/list_test.go +++ b/pkg/cmd/agent-task/list/list_test.go @@ -114,10 +114,12 @@ func Test_listRun(t *testing.T) { wantOut: "no agent tasks found\n", }, { - name: "repo resolution error surfaces", + name: "repo resolution error does not surface", tty: true, baseRepoErr: errors.New("ambiguous repo"), - wantErr: errors.New("ambiguous repo"), + wantErr: nil, + stubs: func(reg *httpmock.Registry) { registerEmptySessionsMock(reg) }, + wantOut: "no agent tasks found\n", }, { name: "repo scoped many sessions (tty)",