{"record":{"id":"57c4e45d2594d41d","repo":"payloadcms/payload","slug":"failed-to-download-url-57c4e4","errorCode":null,"errorMessage":"Failed to download: ${url}","messagePattern":"Failed to download: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/create-payload-app/src/lib/download-template.ts","lineNumber":42,"sourceCode":"    debugLog(`Codeload url: ${url}`)\n    debugLog(`Filter: ${filter}`)\n  }\n\n  await pipeline(\n    await downloadTarStream(url),\n    x({\n      cwd: projectDir,\n      filter: (p) => p.includes(filter),\n      strip: 2 + template.name.split('/').length,\n    }),\n  )\n}\n\nasync function downloadTarStream(url: string) {\n  const res = await fetch(url)\n\n  if (!res.body) {\n    throw new Error(`Failed to download: ${url}`)\n  }\n\n  return Readable.from(res.body as unknown as NodeJS.ReadableStream)\n}\n","sourceCodeStart":24,"sourceCodeEnd":47,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/create-payload-app/src/lib/download-template.ts#L24-L47","documentation":"Identical guard to download-example but for the --template flow. downloadTarStream fetches the payloadcms/payload codeload tarball and throws if res.body is absent. Like the example variant, it does not check res.ok; only a bodyless response triggers this exact line.","triggerScenarios":"Running create-payload-app with --template where codeload returns a response without a body: proxy interception, redirect chain ending in a bodyless response, custom fetch shim, or a deleted/renamed template path producing a bodyless error.","commonSituations":"Corporate proxy blocking codeload.github.com; CI with cached/patched fetch; template.url#<ref> pointing at a removed branch/tag; running on a Node runtime whose fetch returns null body for non-2xx.","solutions":["Confirm reachability of https://codeload.github.com/payloadcms/payload/tar.gz/<branch> (curl -I) and check proxy env (HTTP_PROXY/HTTPS_PROXY).","Re-run with --debug to log the resolved codeload URL and filter string, confirming template.url and branchOrTag.","Ensure the referenced branch/tag exists; pin to a known tag (e.g. latest) if the ref was removed.","Use a Node version with a compliant global fetch and remove conflicting fetch polyfills."],"exampleFix":"// before\nconst res = await fetch(url)\nif (!res.body) {\n  throw new Error(`Failed to download: ${url}`)\n}\n\n// after\nconst res = await fetch(url)\nif (!res.ok || !res.body) {\n  throw new Error(`Failed to download (status ${res.status}): ${url}`)\n}","handlingStrategy":"retry","validationCode":"import { request } from 'undici'\n\nasync function assertCodeloadReachable(branchOrTag: string) {\n  const url = `https://codeload.github.com/payloadcms/payload/tar.gz/${branchOrTag}`\n  const res = await request(url, { method: 'HEAD' })\n  if (res.statusCode >= 400) {\n    throw new Error(`codeload unreachable for ${branchOrTag}: HTTP ${res.statusCode}`)\n  }\n}","typeGuard":null,"tryCatchPattern":"async function downloadWithRetry(url: string, attempts = 3) {\n  for (let i = 0; i < attempts; i++) {\n    const res = await fetch(url)\n    if (res.ok && res.body) return res.body\n    if (i === attempts - 1) throw new Error(`Failed to download: ${url}`)\n    await new Promise((r) => setTimeout(r, 500 * (i + 1)))\n  }\n}","preventionTips":["Ensure network/proxy access to codeload.github.com.","Pin template.url to an existing tag.","Use --debug to verify the resolved URL."],"tags":["network","create-payload-app","fetch","cli"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}