{"record":{"id":"e94a0482d9d1aed7","repo":"coleam00/Archon","slug":"cannot-fetch-rawurl-err-message","errorCode":null,"errorMessage":"Cannot fetch ${rawUrl}: ${err.message}","messagePattern":"Cannot fetch (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/workflow.ts","lineNumber":5128,"sourceCode":"    throw new Error(`Expected directory listing from ${url}, got a single file`);\n  }\n  return data as GitHubContentItem[];\n}\n\n/** Download a file from raw.githubusercontent.com at a pinned SHA. */\nasync function downloadRawFile(\n  owner: string,\n  repo: string,\n  filePath: string,\n  sha: string\n): Promise<string> {\n  const rawUrl = `https://raw.githubusercontent.com/${owner}/${repo}/${sha}/${filePath}`;\n  let res: Response;\n  try {\n    res = await fetch(rawUrl);\n  } catch (error) {\n    const err = error as Error;\n    throw new Error(`Cannot fetch ${rawUrl}: ${err.message}`);\n  }\n  if (!res.ok) {\n    throw new Error(`Source fetch failed: HTTP ${String(res.status)} from ${rawUrl}`);\n  }\n  return res.text();\n}\n\nexport async function workflowInstallCommand(\n  slug: string,\n  cwd: string,\n  force?: boolean\n): Promise<void> {\n  const entries = await fetchMarketplace();\n  const entry = entries.find(e => e.slug === slug);\n\n  if (!entry) {\n    console.error(`Error: Workflow '${slug}' not found in marketplace.`);\n    console.error(\"Run 'archon workflow search' to browse available workflows.\");","sourceCodeStart":5110,"sourceCodeEnd":5146,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/cli/src/commands/workflow.ts#L5110-L5146","documentation":"Wraps a network-level failure of `fetch()` against raw.githubusercontent.com. Before any HTTP status exists, transport errors (DNS, TLS, connection refused/reset, aborts) surface as thrown exceptions; this catch rethrows them with the failing URL and the original message so callers can tell which source file could not be reached.","triggerScenarios":"`downloadRawFile(owner, repo, sha, filePath)` calls `fetch(rawUrl)` and the promise rejects: no network, DNS failure, TLS error, connection reset, or request aborted. Any non-2xx HTTP response does NOT hit this — it goes to error 142 instead.","commonSituations":"Offline or firewalled environment, corporate proxy blocking raw.githubusercontent.com, DNS misconfiguration, VPN down, transient network blip, IPv6 issues in CI containers.","solutions":["Check network connectivity / DNS (`ping raw.githubusercontent.com`, `curl -I <rawUrl>`)","Configure proxy env vars (HTTPS_PROXY) or unset a bad proxy","Retry the install; transient resets often clear on a second attempt","If behind a strict firewall, allowlist raw.githubusercontent.com"],"exampleFix":"// before\ntry { res = await fetch(rawUrl); } catch (e) { throw new Error(`Cannot fetch ${rawUrl}: ${e.message}`); }\n// after\ntry {\n  res = await fetch(rawUrl, { signal: AbortSignal.timeout(30000) });\n} catch (e) {\n  throw new Error(`Cannot fetch ${rawUrl}: ${e.message}`);\n}","handlingStrategy":"retry","validationCode":"// Pre-check reachability before install\nconst probe = await fetch('https://raw.githubusercontent.com/github/gitignore/main/README.md', { method: 'HEAD' }).catch(() => null);\nif (!probe) throw new Error('raw.githubusercontent.com unreachable — check network/proxy');","typeGuard":"function isNetworkError(e: unknown): e is TypeError {\n  return e instanceof TypeError && /fetch|network|ENOTFOUND|ECONNREFUSED/i.test(String((e as Error).cause ?? e.message));\n}","tryCatchPattern":"try {\n  await workflowInstallCommand(slug);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Cannot fetch')) {\n    // transport-level failure: check network/proxy, retry with backoff\n  } else throw e;\n}","preventionTips":["Verify HTTPS_PROXY/HTTPS_PROXY env vars are correct in sandboxed environments","Ensure DNS resolves raw.githubusercontent.com from CI containers","Add bounded retries with backoff around installs in scripts","Prefer wired networks / avoid VPN flaps during long install runs"],"tags":["network","github","fetch","raw-content-download"],"backgroundTag":"fetch-network-error","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}