{"record":{"id":"e3045508ddceaea7","repo":"jackwener/OpenCLI","slug":"failed-to-download-pin-id-geterrormessage-er","errorCode":null,"errorMessage":"Failed to download pin ${id}: ${getErrorMessage(err)}","messagePattern":"Failed to download pin (.+?): (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/pinterest/download.js","lineNumber":51,"sourceCode":"      sourceUrl,\n    );\n    if (!pin || !pin.id) {\n      throw new EmptyResultError('pinterest download', `pin \"${id}\" not found`);\n    }\n    const imageUrl = pickPinImage(pin.images);\n    if (!imageUrl) {\n      throw new CommandExecutionError(`Pin ${id} has no downloadable image (it may be a video or story pin)`);\n    }\n\n    fs.mkdirSync(output, { recursive: true });\n    const ext = path.extname(new URL(imageUrl).pathname) || '.jpg';\n    const destPath = path.join(output, `${id}${ext}`);\n\n    let result;\n    try {\n      result = await httpDownload(imageUrl, destPath, { timeout: 60000 });\n    } catch (err) {\n      throw new CommandExecutionError(`Failed to download pin ${id}: ${getErrorMessage(err)}`);\n    }\n    if (!result.success) {\n      throw new CommandExecutionError(`Failed to download pin ${id}: ${result.error || 'unknown error'}`);\n    }\n\n    return [{\n      pinId: id,\n      status: 'success',\n      size: formatBytes(result.size),\n      path: destPath,\n    }];\n  },\n});\n","sourceCodeStart":33,"sourceCodeEnd":65,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/pinterest/download.js#L33-L65","documentation":"The httpDownload helper threw (network/timeout/ filesystem error) while fetching the pin image with a 60s timeout; the command wraps the failure in CommandExecutionError prefixed with 'Failed to download pin <id>'. This indicates a transport-level problem, not a pin-existence problem.","triggerScenarios":"Network outage or DNS failure during download; image CDN URL expired; response slower than the 60000ms timeout; local write failure creating the destination path.","commonSituations":"Flaky Wi-Fi or corporate proxies; i.pinimg.com rate limiting; long downloads on slow connections exceeding the 60s timeout; running in containers without outbound internet.","solutions":["Retry the command — transient network errors often resolve on retry.","Check general internet connectivity / proxy settings on the machine.","Increase the download timeout if images are large or the connection is slow.","Inspect the wrapped error message (getErrorMessage(err)) for the underlying cause (DNS, TLS, timeout)."],"exampleFix":"// before\nawait cli.download(pinId); // fails on flaky network\n// after\ntry { await cli.download(pinId); } catch (e) { await retry(() => cli.download(pinId), { attempts: 3 }); }","handlingStrategy":"retry","validationCode":"await fetch('https://i.pinimg.com/', { method: 'HEAD' }).catch(() => { throw new Error('no network access to Pinterest CDN'); });","typeGuard":"null","tryCatchPattern":"for (let attempt = 1; attempt <= 3; attempt++) {\n  try { await cli.download(pinId); break; }\n  catch (e) {\n    if (/Failed to download pin/.test(e.message) && attempt < 3) {\n      await new Promise(r => setTimeout(r, attempt * 2000)); // backoff\n    } else throw e;\n  }\n}","preventionTips":["Verify outbound network/DNS before bulk downloads","Use exponential backoff on transient failures","Raise timeouts for slow links or large images","Check proxy/firewall rules in CI and containers"],"tags":["pinterest","network","download-failed","timeout"],"backgroundTag":"download-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}