{"record":{"id":"e7ee7e3f27ac4fa4","repo":"jackwener/OpenCLI","slug":"pin-id-not-found","errorCode":null,"errorMessage":"pin \"${id}\" not found","messagePattern":"pin \"(.+?)\" not found","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"error","filePath":"clis/pinterest/download.js","lineNumber":36,"sourceCode":"    { name: 'pin', type: 'string', positional: true, required: true, help: 'Pin id or pin URL, e.g. 1234567890123456' },\n    { name: 'output', type: 'string', default: './pinterest-downloads', help: 'Output directory' },\n  ],\n  columns: ['pinId', 'status', 'size', 'path'],\n  func: async (page, kwargs) => {\n    const id = parsePinId(kwargs.pin);\n    const output = String(kwargs.output ?? './pinterest-downloads');\n\n    const sourceUrl = `/pin/${id}/`;\n    await page.goto(`${PINTEREST_BASE}${sourceUrl}`);\n\n    const { data: pin } = await pinterestResourceFetch(\n      page,\n      'PinResource',\n      { id, field_set_key: 'detailed' },\n      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'}`);","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/pinterest/download.js#L18-L54","documentation":"The download command fetched the pin via PinResource (field_set_key 'detailed') and got either no pin object or one without an id, meaning the pin id/URL does not resolve. It raises EmptyResultError before attempting any image download.","triggerScenarios":"Calling `pinterest download <pinIdOrUrl>` with a deleted pin, a mistyped id, a malformed URL that still yields an id-like string, or a pin that is private/moderated and invisible to the session.","commonSituations":"Dead links in scraped datasets; pins removed by the pinner or Pinterest moderation; region-blocked content; copying an id from a redirect that no longer exists.","solutions":["Open the pin URL in a browser to confirm it still exists.","Re-check the pin id argument for typos or truncation.","Catch EmptyResultError and mark the pin as unavailable in your batch job.","Try the full pin URL instead of a bare id (or vice versa) so resolution uses the intended source."],"exampleFix":"// before\nawait cli.download('9999999999'); // deleted pin\n// after\ntry { await cli.download(pinUrl); } catch (e) { console.warn('pin unavailable', pinUrl); }","handlingStrategy":"try-catch","validationCode":"if (!idOrUrl || String(idOrUrl).trim().length < 5) throw new Error('provide a valid pin id or URL');\n// optionally probe:\nconst res = await fetch(pinUrl, { method: 'HEAD' });\nif (!res.ok) console.warn('pin may be gone:', pinUrl);","typeGuard":"function looksLikePinId(v) {\n  return /^\\d{6,}$/.test(String(v).trim());\n}","tryCatchPattern":"try {\n  await cli.download(pinId);\n} catch (e) {\n  if (/not found/.test(e.message)) {\n    unavailable.push(pinId); // record and continue batch\n  } else throw e;\n}","preventionTips":["Verify pin URLs resolve in a browser before batch downloads","Expect some pins in any scraped dataset to be deleted","Keep a skip-list for unavailable pins in batch jobs","Refresh pin ids/URLs from live listings, not old caches"],"tags":["pinterest","pin-not-found","empty-result","cli"],"backgroundTag":"resource-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}