cli/cli · error
failed to fetch session resources: %w
Error message
failed to fetch session resources: %w
What it means
Returned by CAPIClient.ListSessions after the pages are fetched and deduplicated: hydrating each session's pull request and user details (hydrateSessionPullRequestsAndUsers) failed. The list call itself worked; the follow-up batched GraphQL lookups for PR node IDs and user node IDs did not. The %w preserves the underlying GraphQL/API error for diagnosis.
Source
Thrown at pkg/cmd/agent-task/capi/sessions.go:290
latestSessions = append(latestSessions, s)
if len(latestSessions) >= limit {
break
}
}
if len(response.Sessions) < pageSize || len(latestSessions) >= limit {
break
}
}
// Drop any above the limit
if len(latestSessions) > limit {
latestSessions = latestSessions[:limit]
}
result, err := c.hydrateSessionPullRequestsAndUsers(latestSessions)
if err != nil {
return nil, fmt.Errorf("failed to fetch session resources: %w", err)
}
return result, nil
}
// GetSession retrieves a specific agent session by ID.
func (c *CAPIClient) GetSession(ctx context.Context, id string) (*Session, error) {
if id == "" {
return nil, fmt.Errorf("missing session ID")
}
u, err := safeurl.JoinPathWithHostPrefix(c.capiBaseURL, "agents", "sessions", id)
if err != nil {
return nil, err
}
req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), http.NoBody)
if err != nil {View on GitHub (pinned to 0eeec0b92e)
Solutions
- Inspect the chained error to identify whether PR or user hydration failed and with which HTTP/GraphQL code
- Run gh auth status and ensure the token has repo + Copilot scopes; refresh if expired
- Wait for rate-limit reset (check X-RateLimit headers / gh api rate_limit) if the inner error is a limit
- Retry the command; already-deleted PR/user references may resolve to a clean list on a narrower query
Defensive patterns
Strategy: retry
Try / catch
result, err := c.ListSessions(ctx, limit)
if err != nil {
if isRateLimitError(err) {
time.Sleep(backoff) // then retry once
result, err = c.ListSessions(ctx, limit)
}
if err != nil {
return nil, fmt.Errorf("failed to fetch session resources: %w", err)
}
} Prevention
- Keep hydration queries batched (the client already batches node IDs) rather than issuing per-session calls
- Ensure the token has repo read scope before listing sessions tied to PRs
- Wrap list operations in a single retry with backoff for transient GraphQL failures
When it happens
Trigger: hydrateSessionPullRequestsAndUsers issues GraphQL/REST lookups for pullRequest node IDs or user details; these fail with token scope errors, rate limits, deleted/private repos referenced by sessions, or deleted users.
Common situations: Token lacks repo read scope so PR hydration 404s; secondary rate limits during large session lists; sessions referencing PRs in repos the token can no longer access; GitHub GraphQL incidents.
Related errors
- failed to resolve Copilot API URL: %w
- ErrNotOnAnyBranch
- failed to look up repositories: %w
- could not fetch tree %s: %w
- could not fetch blob: %w
AI-assisted analysis of cli/cli@0eeec0b92e (2026-08-15).
Data as JSON: /api/errors/ae7f8b003d2eb923.
Report an issue: GitHub.