digitalocean / digitalocean/doctl

gradient agent list panics when the account has no agents

Open
#1,888 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
3.4k
Forks
496
Avg merge
1d 2h
Merged PRs (30d)
31

Description

### Description

`doctl gradient agent list` panics instead of returning an empty list when the authenticated account has no Gradient AI agents.

### Steps to reproduce

1. Authenticate to an account that has no Gradient AI agents.
2. Run:

```sh
doctl gradient agent list --output json
```

### Actual behavior

The command panics:

```text
panic: runtime error: index out of range [0] with length 0

github.com/digitalocean/doctl/do.(*paginatedList).set(...)
do/pagination.go:41
github.com/digitalocean/doctl/do.PaginateResp(...)
do/pagination.go:68
github.com/digitalocean/doctl/do.(*gradientAIService).ListAgents(...)
do/gradientai.go:176
github.com/digitalocean/doctl/commands.RunAgentList(...)
commands/gradientai_agent.go:175
```

### Expected behavior

The command should return an empty JSON array (`[]`) and exit successfully.

### Environment

- doctl version: 1.164.0 (latest stable release)
- OS: macOS 26.5.2
- Architecture: arm64
- Installation method: Homebrew

The panic is reproducible with an active account and an otherwise successful API connection. No access token or account-specific identifiers are included in this report.

Contributor guide

Open the contributing guide

Research direction

Start with do/pagination.go:41 and do/gradientai.go:176, then trace how commands/gradientai_agent.go:175 handles the agent list response. Reproduce with `doctl gradient agent list --output json` against an account with no agents, and verify the command exits successfully with an empty JSON array instead of panicking.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
75/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.