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.
This commit is contained in:
parent
e750e71288
commit
3197193e42
2 changed files with 10 additions and 6 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue