{"record":{"id":"922ab4f1de1387ee","repo":"oven-sh/bun","slug":"failed-to-download-packer-response-status","errorCode":null,"errorMessage":"Failed to download Packer: ${response.status}","messagePattern":"Failed to download Packer: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/machine.mjs","lineNumber":1346,"sourceCode":"  }\n\n  // Check if we have a local copy\n  const localPacker = join(tmpdir(), \"packer\");\n  if (existsSync(localPacker)) {\n    return localPacker;\n  }\n\n  // Download Packer\n  const version = \"1.15.0\";\n  const platform = process.platform === \"win32\" ? \"windows\" : process.platform;\n  const packerArch = process.arch === \"arm64\" ? \"arm64\" : \"amd64\";\n  const url = `https://releases.hashicorp.com/packer/${version}/packer_${version}_${platform}_${packerArch}.zip`;\n\n  console.log(`[packer] Downloading Packer ${version}...`);\n  const zipPath = join(tmpdir(), \"packer.zip\");\n\n  const response = await fetch(url);\n  if (!response.ok) throw new Error(`Failed to download Packer: ${response.status}`);\n  const buffer = Buffer.from(await response.arrayBuffer());\n  writeFileSync(zipPath, buffer);\n\n  // Extract\n  await spawnSafe([\"unzip\", \"-o\", zipPath, \"-d\", tmpdir()], { stdio: \"inherit\" });\n  chmodSync(localPacker, 0o755);\n\n  console.log(`[packer] Installed Packer ${version}`);\n  return localPacker;\n}\n\nasync function main() {\n  const { positionals } = parseArgs({\n    allowPositionals: true,\n    strict: false,\n  });\n\n  const [command] = positionals;","sourceCodeStart":1328,"sourceCodeEnd":1364,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/scripts/machine.mjs#L1328-L1364","documentation":"Thrown by scripts/machine.mjs while installing HashiCorp Packer for Windows Azure image builds. The script fetches a pinned release zip (packer_1.15.0_<platform>_<arch>.zip) from releases.hashicorp.com and this error means the HTTP response completed but response.ok was false. The numeric status is embedded so you can tell a 404 (bad URL) from a 5xx/proxy failure.","triggerScenarios":"Running `machine.mjs create-image/publish-image` for Azure + windows when no usable Packer is already installed locally (the download branch only runs then). A 404 happens when the computed platform/arch pair has no published release; 403/5xx happen behind corporate proxies or when the release CDN is flaky.","commonSituations":"CI runner without outbound internet or with an HTTPS_PROXY that blocks releases.hashicorp.com; the pinned version 1.15.0 lacking a build for the runner's platform (e.g. an unusual arch mapping); transient CDN errors during CI.","solutions":["curl -fL the exact URL printed by the `[packer] Downloading` log line to see the real status code","Verify the runner maps to a published release: process.platform win32→'windows', arch arm64→'arm64' else 'amd64'; check the release listing for 1.15.0","Fix network/proxy (HTTPS_PROXY/HTTP_PROXY) or re-run — the CDN is occasionally transient","Pre-install Packer on PATH or place it at the local cache path so the function returns before reaching the download"],"exampleFix":"// before\nconst response = await fetch(url);\nif (!response.ok) throw new Error(`Failed to download Packer: ${response.status}`);\n\n// after — retry transient failures, fail fast on 4xx\nlet response: Response | undefined;\nfor (let attempt = 0; attempt < 3 && !response?.ok; attempt++) {\n  response = await fetch(url);\n  if (response.status >= 500 && attempt < 2) continue;\n}\nif (!response?.ok) throw new Error(`Failed to download Packer: ${response.status}`);","handlingStrategy":"retry","validationCode":"import { existsSync } from \"node:fs\";\nimport { localPacker } from \"./machine.mjs\"; // or replicate its path\n\n// Skip the download branch entirely when Packer is already usable.\nif (!existsSync(localPacker)) {\n  const url = \"https://releases.hashicorp.com/packer/1.15.0/packer_1.15.0_linux_amd64.zip\";\n  const head = await fetch(url, { method: \"HEAD\" });\n  if (!head.ok) throw new Error(`Packer release unreachable (HTTP ${head.status}) — fix network or URL`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await ensurePacker();\n} catch (err) {\n  if (/Failed to download Packer: (5\\d\\d|429)/.test(String(err))) {\n    await sleep(5_000); // simple backoff, then one retry\n    return ensurePacker();\n  }\n  throw err; // 4xx (bad URL/platform) will not heal — rethrow\n}","preventionTips":["Pre-install the pinned Packer version on CI runners or bake it into the image so the download path never runs","Pin the version only to combinations that exist on releases.hashicorp.com for your runner platform/arch","CI networks: allowlist releases.hashicorp.com through the proxy"],"tags":["network","download","packer","ci","azure"],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}