{"record":{"id":"915d8155f489847f","repo":"garrytan/gstack","slug":"download-failed-http-status-response-statust","errorCode":null,"errorMessage":"Download failed: HTTP ${status} ${response.statusText()}","messagePattern":"Download failed: HTTP (.+?) (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"browse/src/write-commands.ts","lineNumber":1278,"sourceCode":"        }\n        if (buffer.length > 200 * 1024 * 1024) {\n          throw new Error('File too large (>200MB).');\n        }\n      } else {\n        // Strategy 1: Direct URL via page.request.fetch().\n        // Gate the URL through the same validator `goto` uses. Without\n        // this check, download + scrape bypass the navigation\n        // blocklist and a caller with write scope can read\n        // http://169.254.169.254/latest/meta-data/ (AWS IMDSv1), the\n        // GCP/Azure metadata equivalents, or any internal IPv4/IPv6\n        // the server happens to route to. The response body is then\n        // returned to the caller (base64) or written to disk where\n        // GET /file serves it back.\n        await validateNavigationUrl(url);\n        const response = await page.request.fetch(url, { timeout: 30000 });\n        const status = response.status();\n        if (status >= 400) {\n          throw new Error(`Download failed: HTTP ${status} ${response.statusText()}`);\n        }\n        contentType = response.headers()['content-type'] || 'application/octet-stream';\n        buffer = Buffer.from(await response.body());\n        if (buffer.length > 200 * 1024 * 1024) {\n          throw new Error('File too large (>200MB).');\n        }\n      }\n\n      // --base64 mode: return inline\n      if (isBase64) {\n        if (buffer.length > 10 * 1024 * 1024) {\n          throw new Error('File too large for --base64 (>10MB). Use disk download + GET /file instead.');\n        }\n        const mimeType = contentType.split(';')[0].trim();\n        return `data:${mimeType};base64,${buffer.toString('base64')}`;\n      }\n\n      // Write to disk","sourceCodeStart":1260,"sourceCodeEnd":1296,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/write-commands.ts#L1260-L1296","documentation":"Error \"Download failed: HTTP ${status} ${response.statusText()}\" thrown in garrytan/gstack.","triggerScenarios":"Thrown at browse/src/write-commands.ts:1278 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"94993f74012782fd94416dd44b8314f6363a13a4","analyzedAt":"2026-08-12T04:06:23.140Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}