{"record":{"id":"f7c092fcf9034bd1","repo":"jackwener/OpenCLI","slug":"pinterest-request-failed-raw-fetcherror","errorCode":null,"errorMessage":"Pinterest request failed: ${raw.__fetchError}","messagePattern":"Pinterest request failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/pinterest/utils.js","lineNumber":201,"sourceCode":"        }\n        try { return JSON.parse(text); } catch { return { __malformed: true }; }\n      } catch (err) {\n        return { __fetchError: (err && err.message) || String(err) };\n      }\n    })()\n  `;\n}\n\n/** POST a resource action ('get' | 'create' | 'update' | 'delete'); returns { data, results, bookmark }. */\nexport async function pinterestResourceFetch(page, resource, options, sourceUrl, action = 'get') {\n  const data = JSON.stringify({ options, context: {} });\n  const body = `source_url=${encodeURIComponent(sourceUrl)}&data=${encodeURIComponent(data)}`;\n  const url = `/resource/${resource}/${action}/`;\n\n  const raw = unwrapEvaluateResult(await page.evaluate(resourceFetchScript(url, body)));\n\n  if (raw?.__fetchError) {\n    throw new CommandExecutionError(`Pinterest request failed: ${raw.__fetchError}`);\n  }\n  if (raw?.__noCsrf) {\n    throw new CommandExecutionError(\n      'Pinterest did not set a csrftoken cookie for this page',\n      'Open https://www.pinterest.com in Chrome (logged in) and retry',\n    );\n  }\n  if (raw?.__httpError) {\n    const status = raw.__httpError;\n    // Reads work anonymously, so their 403 is a rejected request, not a login prompt;\n    // writes genuinely need login, so treat their 403 as auth too.\n    if (status === 401 || (WRITE_ACTIONS.has(action) && status === 403)) {\n      // Pinterest also answers 401 for writes it refuses on a logged-in session (e.g. editing the\n      // link of a scraped pin), so pass its own message through instead of only saying \"log in\".\n      throw new AuthRequiredError(\n        PINTEREST_DOMAIN,\n        raw.message\n          ? `Pinterest refused this write: ${raw.message}`","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/pinterest/utils.js#L183-L219","documentation":"pinterestResourceFetch runs an in-page fetch against Pinterest's /resource/ endpoints via Chrome. When the injected script reports a __fetchError (network failure, aborted request, or script exception), the library wraps it as CommandExecutionError prefixed 'Pinterest request failed'.","triggerScenarios":"Chrome page is offline or Pinterest is unreachable; page.evaluate throws and the failure is surfaced as __fetchError; the resource URL/body fails to fetch due to DNS, TLS, or connection reset; navigating away mid-request.","commonSituations":"Laptop lost Wi-Fi mid-command; corporate proxy blocks pinterest.com; Chrome tab crashed or was closed during the call; Pinterest served a captcha/interstitial that broke the in-page fetch.","solutions":["Check network connectivity and that pinterest.com loads in the attached Chrome window","Retry the command; transient connection failures often clear","Disable proxy/VPN or corporate blocking for pinterest.com","Reload the Pinterest tab in Chrome so the page is in a healthy state before retrying"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if (!navigator.onLine) throw new Error('offline: Pinterest calls require connectivity');\nconst ok = await fetch('https://www.pinterest.com', { method: 'HEAD' }).then(r => r.ok).catch(() => false);\nif (!ok) throw new Error('pinterest.com unreachable');","typeGuard":"null","tryCatchPattern":"try { await cmd.board(target); } catch (e) { if (/Pinterest request failed/.test(e.message)) { await sleep(2000); return cmd.board(target); } throw e; }","preventionTips":["Check connectivity before batch operations","Keep the attached Chrome tab open and healthy during calls","Avoid closing or navigating the Pinterest tab mid-command","Add backoff between scripted resource calls"],"tags":["network","fetch","pinterest","chrome"],"backgroundTag":"fetch-network-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}