diff --git a/pkg/cmd/agent-task/list/list.go b/pkg/cmd/agent-task/list/list.go index d2e717b72..5b5ff0c38 100644 --- a/pkg/cmd/agent-task/list/list.go +++ b/pkg/cmd/agent-task/list/list.go @@ -104,11 +104,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 fc45b34d2..a2c9d62ea 100644 --- a/pkg/cmd/agent-task/list/list_test.go +++ b/pkg/cmd/agent-task/list/list_test.go @@ -159,10 +159,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)",