davila7/claude-code-templates · warning

Warning: Could not fetch category ${item.name}:

Error message

Warning: Could not fetch category ${item.name}:

What it means

While fetching the catalog of agents from the GitHub API (repo contents per category), each per-category request is wrapped in its own try/catch; this warning fires when one category's fetch fails (rate limit 403, network error, or a category folder that returns an unexpected shape). Other categories still load, so the resulting agent list is only partially populated.

Source

Thrown at cli-tool/src/index.js:1506

        });
      } else if (item.type === 'dir') {
        // Category directory, fetch its contents
        try {
          const categoryResponse = await fetch(`https://api.github.com/repos/davila7/claude-code-templates/contents/cli-tool/components/agents/${item.name}`);
          if (categoryResponse.ok) {
            const categoryContents = await categoryResponse.json();
            for (const categoryItem of categoryContents) {
              if (categoryItem.type === 'file' && categoryItem.name.endsWith('.md')) {
                agents.push({
                  name: categoryItem.name.replace('.md', ''),
                  path: `${item.name}/${categoryItem.name.replace('.md', '')}`,
                  category: item.name
                });
              }
            }
          }
        } catch (error) {
          console.warn(`Warning: Could not fetch category ${item.name}:`, error.message);
        }
      }
    }
    
    return agents;
  } catch (error) {
    console.warn('Warning: Could not fetch agents, using fallback list');
    // Comprehensive fallback list if all methods fail
    return [
      { name: 'frontend-developer', path: 'development-team/frontend-developer', category: 'development-team' },
      { name: 'backend-developer', path: 'development-team/backend-developer', category: 'development-team' },
      { name: 'fullstack-developer', path: 'development-team/fullstack-developer', category: 'development-team' },
      { name: 'api-security-audit', path: 'api-security-audit', category: 'root' },
      { name: 'database-optimization', path: 'database-optimization', category: 'root' },
      { name: 'react-performance-optimization', path: 'react-performance-optimization', category: 'root' }
    ];
  }
}

View on GitHub (pinned to a0851ed10c)

Solutions

  1. Wait for the rate-limit window to reset (check x-ratelimit-reset) or supply a GITHUB_TOKEN to lift the limit to 5000/hr.
  2. Retry with backoff around the fetch call for transient 5xx/network errors.
  3. Verify network access to api.github.com (curl -I https://api.github.com) if behind a proxy.
  4. Check the repo layout — a category that no longer exists yields responses the parser can't handle.
Defensive patterns

Strategy: retry

Validate before calling

if (res.status === 403 && res.headers.get('x-ratelimit-remaining') === '0') await sleepUntilReset(res.headers.get('x-ratelimit-reset'));

Type guard

Array.isArray(data) ? data : []

Try / catch

catch (e) { if (isRetryable(e)) await backoffRetry(fetchCategory, item.name); else console.warn(`Could not fetch category ${item.name}`, e.message); }

Prevention

When it happens

Trigger: Calling getAvailableAgents() when one of the per-category `gh` API calls fails: GitHub secondary rate limits during bursts, a flaky network, an HTTP 403 with x-ratelimit-remaining: 0, or a category name that returns a non-array JSON body.

Common situations: CI pipelines hammering the GitHub unauthenticated API (60 req/hr limit), corporate proxies/firewalls dropping requests, or a renamed/removed category directory in the repo making the response shape unexpected.

Related errors


AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28). Data as JSON: /api/errors/4cf70b1e07d77435. Report an issue: GitHub.