upstash/context7 · warning

Failed to fetch

Error message

Failed to fetch ${item.path}: ${fileResponse.status}

What it means

This warning is emitted by downloadSkillTree while fetching individual skill files from GitHub raw content. When a file's HTTP response is not ok (e.g. 404 or 403), the file is skipped with this message rather than failing the whole download, so the resulting skill tree may be incomplete. It indicates a per-file fetch failure for a path that the GitHub API listed.

Solutions

  1. Verify the branch/tag passed to downloadSkillTree actually contains the reported file (check it on GitHub).
  2. Ensure ghHeaders include a valid GitHub token if the repo is private or rate limits are being hit.
  3. Refresh the skillFiles tree listing so it doesn't reference deleted/renamed paths.
  4. Retry the download later if the status was 403/429 (rate limit or transient GitHub issue).

Example fix

// before
await downloadSkillTree({ owner: 'org', repo: 'skills', branch: 'main' });
// after
await downloadSkillTree({ owner: 'org', repo: 'skills', branch: 'main', headers: { Authorization: `Bearer ${GITHUB_TOKEN}` } });
Defensive patterns

Strategy: retry

Validate before calling

// before download
const tree = await fetchTree(owner, repo, branch);
const missing = tree.filter(f => !f.sha);
if (missing.length) console.warn('stale tree entries', missing);

Prevention

When it happens

Trigger: Calling downloadSkillTree (via its result caller) when GitHub returns a non-2xx status for `${GITHUB_RAW}/${owner}/${repo}/${branch}/${item.path}` — typically the file was deleted or renamed after the tree listing, the branch/tag is wrong, or a private repo returns 404/403 without auth.

Common situations: Pinning a stale branch that no longer contains every file in the tree; fetching from a private repo where raw.githubusercontent.com lacks credentials; rate-limiting (403) from GitHub; a recently moved/renamed skill path.

Related errors


AI-assisted analysis of upstash/context7@4416fb855b (2026-09-16). Data as JSON: /api/errors/16b8437dfb24050c. Report an issue: GitHub.

Appendix: source

Thrown at packages/cli/src/utils/github.ts:286

        : "";
    return { files: [], error: `GitHub API error: ${treeData.error}${hint}` };
  }

  const skillFiles = treeData.tree.filter(
    (item) => item.type === "blob" && item.path.startsWith(skillPath + "/")
  );

  if (skillFiles.length === 0) {
    return { files: [], error: `No files found in ${skillPath}` };
  }

  const files: SkillFile[] = [];
  for (const item of skillFiles) {
    const rawUrl = `${GITHUB_RAW}/${owner}/${repo}/${branch}/${item.path}`;
    const fileResponse = await fetch(rawUrl, { headers: ghHeaders });

    if (!fileResponse.ok) {
      console.warn(`Failed to fetch ${item.path}: ${fileResponse.status}`);
      continue;
    }

    const content = await fileResponse.text();
    const relativePath = item.path.slice(skillPath.length + 1);

    // Reject paths that attempt directory traversal
    if (relativePath.includes("..")) {
      console.warn(`Skipping file with unsafe path: ${item.path}`);
      continue;
    }

    files.push({
      path: relativePath,
      content,
    });
  }

View on GitHub (pinned to 4416fb855b)