jackwener/OpenCLI · error · ArgumentError

image URL must be http(s): ${value}

Error message

image URL must be http(s): ${value}

What it means

This ArgumentError is thrown by requireImageUrl in clis/pinterest/pin-create.js when the --image positional argument parses as a valid URL but its protocol is not http: or https:. Pinterest can only fetch remote images over HTTP(S) (method 'scraped'), so schemes like file:, data:, ftp: or javascript: are rejected before any network call is made.

Source

Thrown at clis/pinterest/pin-create.js:16

// Pinterest pin-create — create a pin from a remote image URL onto a board (PinResource/create).
import { cli, Strategy } from '@jackwener/opencli/registry';
import { ArgumentError, CommandExecutionError } from '@jackwener/opencli/errors';
import { PINTEREST_BASE, movePinToSection, pinterestResourceCreate, resolveBoardId, resolveBoardTarget, resolveSection } from './utils.js';

function requireImageUrl(raw) {
  const value = String(raw ?? '').trim();
  if (!value) throw new ArgumentError('image is required (a remote image URL)');
  let parsed;
  try {
    parsed = new URL(value);
  } catch {
    throw new ArgumentError(`image must be a remote image URL (got "${raw}")`);
  }
  if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
    throw new ArgumentError(`image URL must be http(s): ${value}`);
  }
  return value;
}

cli({
  site: 'pinterest',
  name: 'pin-create',
  access: 'write',
  description: 'Create a pin from a remote image URL onto a board',
  domain: 'www.pinterest.com',
  strategy: Strategy.COOKIE,
  args: [
    { name: 'image', type: 'string', positional: true, required: true, help: 'Direct image URL Pinterest can fetch (not a page URL), e.g. https://example.com/image.jpg' },
    { name: 'board', type: 'string', required: true, help: 'Target board: <username>/<slug>, board URL, or board id (a new pin always needs a board)' },
    { name: 'section', type: 'string', default: '', help: 'Optional board section id or slug' },
    { name: 'title', type: 'string', default: '', help: 'Pin title' },
    // Pinterest ignores description for scraped pins (it derives one from the source page).
    { name: 'description', type: 'string', default: '', help: 'Pin description (Pinterest may override it for scraped images)' },

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Replace the argument with a publicly reachable http:// or https:// direct image URL (e.g. https://example.com/image.jpg), not a local path or data URI
  2. If the image is local, upload it to a host (or an image CDN/object storage with a public URL) first and pass that URL
  3. If you passed an HTML page URL, use the direct image file URL instead — the help text says Pinterest fetches the image itself
  4. Check for typo'd schemes such as `http:/example.com/i.jpg` or leading characters that make `new URL` pick up the wrong protocol

Example fix

// before
$ opencli pinterest pin-create file:///tmp/photo.jpg --board me/ideas
// after
$ opencli pinterest pin-create https://cdn.example.com/photo.jpg --board me/ideas
Defensive patterns

Strategy: validation

Validate before calling

function assertHttpImageUrl(url) {
  const parsed = new URL(String(url ?? '').trim());
  if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
    throw new Error(`image URL must be http(s): ${url}`);
  }
  return parsed.href;
}

Type guard

function isHttpImageUrl(value) {
  try {
    const u = new URL(String(value).trim());
    return u.protocol === 'http:' || u.protocol === 'https:';
  } catch { return false; }
}

Try / catch

try {
  await run(['pin-create', imageUrl, '--board', board]);
} catch (e) {
  if (/image URL must be http\(s\)/.test(e.message)) {
    throw new Error(`Upload ${imageUrl} to a web host first; local/data URLs are not accepted`);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling `pin-create` with an image argument whose URL scheme is non-http(s), e.g. `file:///home/user/pic.png`, `data:image/png;base64,...`, `ftp://host/img.jpg`. The URL must parse via `new URL()` but fail the protocol check at clis/pinterest/pin-create.js:15-17.

Common situations: Passing a local file path like `/home/me/photo.jpg` (on Windows `C:\pics\a.jpg` may even parse as a URL with scheme `c:`); embedding a base64 data URI expecting upload behavior; using an internal scheme from another tool's config.

Related errors


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