jackwener/OpenCLI · error · CommandExecutionError

Pinterest request failed

Error message

Pinterest request failed: ${raw.__fetchError}

What it means

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'.

Solutions

  1. Check network connectivity and that pinterest.com loads in the attached Chrome window
  2. Retry the command; transient connection failures often clear
  3. Disable proxy/VPN or corporate blocking for pinterest.com
  4. Reload the Pinterest tab in Chrome so the page is in a healthy state before retrying
Defensive patterns

Strategy: retry

Validate before calling

if (!navigator.onLine) throw new Error('offline: Pinterest calls require connectivity');
const ok = await fetch('https://www.pinterest.com', { method: 'HEAD' }).then(r => r.ok).catch(() => false);
if (!ok) throw new Error('pinterest.com unreachable');

Type guard

null

Try / catch

try { await cmd.board(target); } catch (e) { if (/Pinterest request failed/.test(e.message)) { await sleep(2000); return cmd.board(target); } throw e; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/f7c092fcf9034bd1. Report an issue: GitHub.

Appendix: source

Thrown at clis/pinterest/utils.js:201

        }
        try { return JSON.parse(text); } catch { return { __malformed: true }; }
      } catch (err) {
        return { __fetchError: (err && err.message) || String(err) };
      }
    })()
  `;
}

/** POST a resource action ('get' | 'create' | 'update' | 'delete'); returns { data, results, bookmark }. */
export async function pinterestResourceFetch(page, resource, options, sourceUrl, action = 'get') {
  const data = JSON.stringify({ options, context: {} });
  const body = `source_url=${encodeURIComponent(sourceUrl)}&data=${encodeURIComponent(data)}`;
  const url = `/resource/${resource}/${action}/`;

  const raw = unwrapEvaluateResult(await page.evaluate(resourceFetchScript(url, body)));

  if (raw?.__fetchError) {
    throw new CommandExecutionError(`Pinterest request failed: ${raw.__fetchError}`);
  }
  if (raw?.__noCsrf) {
    throw new CommandExecutionError(
      'Pinterest did not set a csrftoken cookie for this page',
      'Open https://www.pinterest.com in Chrome (logged in) and retry',
    );
  }
  if (raw?.__httpError) {
    const status = raw.__httpError;
    // Reads work anonymously, so their 403 is a rejected request, not a login prompt;
    // writes genuinely need login, so treat their 403 as auth too.
    if (status === 401 || (WRITE_ACTIONS.has(action) && status === 403)) {
      // Pinterest also answers 401 for writes it refuses on a logged-in session (e.g. editing the
      // link of a scraped pin), so pass its own message through instead of only saying "log in".
      throw new AuthRequiredError(
        PINTEREST_DOMAIN,
        raw.message
          ? `Pinterest refused this write: ${raw.message}`

View on GitHub (pinned to 49907e53dc)