crewAIInc/crewAI · error · SystemExit
Failed to fetch templates from GitHub: {e}
Error message
Failed to fetch templates from GitHub: {e} What it means
Raised while paginating through the GitHub API (`/orgs/{GITHUB_ORG}/repos`) to build the template catalog for `crewai template list/add`. Any httpx.HTTPError — connection failure, timeout (15s), DNS failure, or an HTTP status error from raise_for_status() (403 rate-limit, 5xx) — triggers it. The CLI prints the red message and exits 1, chaining the original exception.
Source
Thrown at lib/cli/src/crewai_cli/remote_template/main.py:170
console.print(panel)
def _fetch_templates(self) -> list[dict[str, Any]]:
"""Fetch all template repos from the GitHub org."""
templates: list[dict[str, Any]] = []
page = 1
while True:
url = f"{GITHUB_API_BASE}/orgs/{GITHUB_ORG}/repos"
params: dict[str, str | int] = {
"per_page": 100,
"page": page,
"type": "public",
}
try:
response = httpx.get(url, params=params, timeout=15)
response.raise_for_status()
except httpx.HTTPError as e:
click.secho(f"Failed to fetch templates from GitHub: {e}", fg="red")
raise SystemExit(1) from e
repos = response.json()
if not repos:
break
templates.extend(
repo
for repo in repos
if repo["name"].startswith(TEMPLATE_PREFIX) and not repo.get("private")
)
page += 1
templates.sort(key=lambda r: r["name"])
return templates
def _resolve_repo_name(self, name: str) -> str | None:
"""Resolve user input to a full repo name, or None if not found."""View on GitHub (pinned to 754d7323be)
Solutions
- Check connectivity: `curl -I https://api.github.com/orgs/crewAIInc/repos` from the same machine.
- If behind a proxy, set HTTPS_PROXY/HTTP_PROXY (httpx honors these env vars).
- If rate-limited (403/429 in the message), wait or set GITHUB_API_TOKEN-style auth if the CLI/deployment supports it, and reduce how often the listing runs.
- Retry after a short wait for transient 5xx/network blips.
Example fix
# before $ crewai template list # Failed to fetch templates from GitHub: Client error '403 Forbidden' ... # after $ export HTTPS_PROXY=http://proxy.corp:8080 # or wait out the rate limit $ crewai template list
Defensive patterns
Strategy: retry
Validate before calling
import httpx
resp = httpx.get(
"https://api.github.com/orgs/crewAIInc/repos",
params={"per_page": 1, "page": 1, "type": "public"},
timeout=15,
)
resp.raise_for_status() # probe before running the CLI command Try / catch
import time, httpx
for attempt in range(3):
try:
run_template_list()
break
except SystemExit as e:
# transient GitHub 5xx / rate limits: back off and retry
time.sleep(2 ** attempt)
else:
raise Prevention
- Cache the template list in automation instead of calling `crewai template list` repeatedly.
- Configure proxy env vars (HTTPS_PROXY) in corporate networks before invoking the CLI.
- Watch for 403/429 in the message — that is rate limiting, not connectivity; space out calls.
When it happens
Trigger: GET https://api.github.com/orgs/crewAIInc/repos?per_page=100&page=N with timeout=15 failing: no network, corporate proxy blocking api.github.com, GitHub secondary rate limits returning 403/429 (raise_for_status raises HTTPStatusError, an httpx.HTTPError subclass), or GitHub 5xx incidents.
Common situations: CI runners behind restrictive firewalls/proxies needing HTTP(S)_PROXY env vars; scripts hitting `crewai template list` in a loop until GitHub's unauthenticated rate limit (60 req/hr per IP) is exhausted; air-gapped environments; transient GitHub outages.
Related errors
- Failed to download template: {e}
- Unable to access repository {repo_name}: {e}
- Error. A valid pyproject.toml file is required. Check that a
- Invalid JSON response from {oauth_endpoint}
- Failed to connect to enterprise URL: {e!s}
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/4e76034bbdb99d16.
Report an issue: GitHub.