jackwener/OpenCLI · error · ArgumentError
image must be a remote image URL (got "${raw}")
Error message
image must be a remote image URL (got "${raw}") What it means
requireImageUrl validates that the image value parses as a URL; if new URL(value) throws, the argument is not a valid URL and ArgumentError is raised with the raw input echoed. This typically means a file path, bare hostname, or garbled string was passed instead of a full URL.
Source
Thrown at clis/pinterest/pin-create.js:13
// 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' },View on GitHub (pinned to 49907e53dc)
Solutions
- Prefix the value with https:// if only a host/path was given.
- Upload local files to accessible storage (S3, GitHub, an image host) and pass that URL.
- URL-encode spaces and special characters in the image URL.
- Pre-validate with `new URL(value)` in your script before calling the command.
Example fix
// before
await cli.pinCreate({ board: 'user/board', image: './photo.jpg' });
// after
await cli.pinCreate({ board: 'user/board', image: 'https://cdn.example.com/photo.jpg' }); Defensive patterns
Strategy: validation
Validate before calling
let url = String(image ?? '').trim();
if (url && !/^https?:\/\//i.test(url)) url = 'https://' + url;
try { new URL(url); } catch { throw new Error(`image is not a valid URL: ${image}`); } Type guard
function isHttpUrl(v) {
if (typeof v !== 'string') return false;
try { const u = new URL(v); return u.protocol === 'http:' || u.protocol === 'https:'; }
catch { return false; }
} Try / catch
try {
await cli.pinCreate({ board, image });
} catch (e) {
if (/must be a remote image URL/.test(e.message)) {
console.error('got:', e.message.match(/got "(.*)"/)?.[1], '— pass a full http(s) URL');
} else throw e;
} Prevention
- Always include the http(s):// scheme in image URLs
- Upload local files to a host instead of passing paths
- URL-encode spaces and special characters
- Run new URL(value) in your own code as a pre-flight check
When it happens
Trigger: Passing a local path like ./photo.jpg or /home/user/img.png; a URL missing its scheme (example.com/photo.jpg); a value with unencoded spaces breaking URL parsing.
Common situations: Users assuming local files are supported; shell variables losing scheme during string manipulation; copy-pasting image paths instead of image URLs.
Related errors
- Unknown privacy "${privacy}". Valid: ${PRIVACY.join(', ')}
- nothing to update
- image is required (a remote image URL)
- INVALID_ARGUMENT
- INVALID_ARGUMENT
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a9aca5b010bf551a.
Report an issue: GitHub.