{"record":{"id":"c5ca5a29a580f306","repo":"Hmbown/CodeWhale","slug":"too-many-redirects-while-checking-url","errorCode":null,"errorMessage":"Too many redirects while checking ${url}","messagePattern":"Too many redirects while checking (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"npm/codewhale/scripts/verify-release-assets.js","lineNumber":67,"sourceCode":"function assertPackageVersionMatchesBinaryVersion(version) {\n  if (packageVersionMatchesBinaryVersion(version)) {\n    return;\n  }\n  if (process.env.CODEWHALE_ALLOW_NPM_BINARY_MISMATCH === \"1\") {\n    console.log(\n      `npm package version ${pkg.version} points at binary release ${version} (allowed packaging-only mismatch).`,\n    );\n    return;\n  }\n  throw new Error(\n    `npm package version ${pkg.version} does not match codewhaleBinaryVersion ${version}. ` +\n      \"Set CODEWHALE_ALLOW_NPM_BINARY_MISMATCH=1 only for an intentional packaging-only npm release.\",\n  );\n}\n\nfunction requestStatus(url, method = \"HEAD\", redirects = 0) {\n  if (redirects > 10) {\n    throw new Error(`Too many redirects while checking ${url}`);\n  }\n  const client = url.startsWith(\"https:\") ? https : http;\n  return new Promise((resolve, reject) => {\n    const req = client.request(\n      url,\n      {\n        method,\n        headers: {\n          \"User-Agent\": \"codewhale-npm-release-check\",\n        },\n      },\n      (res) => {\n        const status = res.statusCode || 0;\n        const location = res.headers.location;\n        res.resume();\n        if (status >= 300 && status < 400 && location) {\n          const next = new URL(location, url).toString();\n          resolve(requestStatus(next, method, redirects + 1));","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/npm/codewhale/scripts/verify-release-assets.js#L49-L85","documentation":"requestStatus performs a HEAD (or GET) HTTP status check on a release asset URL, following redirects recursively with a counter. More than 10 redirects indicates a redirect loop or misconfigured CDN, so it aborts instead of following forever.","triggerScenarios":"verifyAsset → requestStatus on a GitHub releases/CDN URL that returns a redirect chain longer than 10 hops, or a redirect loop (A→B→A).","commonSituations":"Misconfigured release mirror or custom CODEWHALE download URL; GitHub CDN outages; corporate proxies bouncing requests between hosts.","solutions":["Check the asset URL for a redirect loop (curl -IL <url>)","Verify any custom download mirror/proxy configuration","Retry later if it is a transient GitHub/CDN issue","Use the direct github.com release URL instead of a mirror"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"const { execSync } = require(\"child_process\");\nconst hops = execSync(`curl -sIL -o /dev/null -w '%{num_redirects}' ${url}`).toString();\nif (Number(hops) > 10) throw new Error(`Redirect loop for ${url}`);","typeGuard":null,"tryCatchPattern":"try { await verifyAsset(url, label); } catch (e) { if (/Too many redirects/.test(e.message)) { await new Promise(r => setTimeout(r, 2000)); return verifyAsset(url, label); } throw e; }","preventionTips":["Use official GitHub release URLs, not untrusted mirrors","Monitor CDN/proxy config changes","Bound retries and surface the URL in logs"],"tags":["http","redirect","network","release"],"backgroundTag":"http-error-response","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}