{"record":{"id":"a9aca5b010bf551a","repo":"jackwener/OpenCLI","slug":"image-must-be-a-remote-image-url-got-raw","errorCode":null,"errorMessage":"image must be a remote image URL (got \"${raw}\")","messagePattern":"image must be a remote image URL \\(got \"(.+?)\"\\)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/pinterest/pin-create.js","lineNumber":13,"sourceCode":"// Pinterest pin-create — create a pin from a remote image URL onto a board (PinResource/create).\nimport { cli, Strategy } from '@jackwener/opencli/registry';\nimport { ArgumentError, CommandExecutionError } from '@jackwener/opencli/errors';\nimport { PINTEREST_BASE, movePinToSection, pinterestResourceCreate, resolveBoardId, resolveBoardTarget, resolveSection } from './utils.js';\n\nfunction requireImageUrl(raw) {\n  const value = String(raw ?? '').trim();\n  if (!value) throw new ArgumentError('image is required (a remote image URL)');\n  let parsed;\n  try {\n    parsed = new URL(value);\n  } catch {\n    throw new ArgumentError(`image must be a remote image URL (got \"${raw}\")`);\n  }\n  if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n    throw new ArgumentError(`image URL must be http(s): ${value}`);\n  }\n  return value;\n}\n\ncli({\n  site: 'pinterest',\n  name: 'pin-create',\n  access: 'write',\n  description: 'Create a pin from a remote image URL onto a board',\n  domain: 'www.pinterest.com',\n  strategy: Strategy.COOKIE,\n  args: [\n    { 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' },\n    { name: 'board', type: 'string', required: true, help: 'Target board: <username>/<slug>, board URL, or board id (a new pin always needs a board)' },\n    { name: 'section', type: 'string', default: '', help: 'Optional board section id or slug' },","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/pinterest/pin-create.js#L1-L31","documentation":"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.","triggerScenarios":"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.","commonSituations":"Users assuming local files are supported; shell variables losing scheme during string manipulation; copy-pasting image paths instead of image URLs.","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."],"exampleFix":"// before\nawait cli.pinCreate({ board: 'user/board', image: './photo.jpg' });\n// after\nawait cli.pinCreate({ board: 'user/board', image: 'https://cdn.example.com/photo.jpg' });","handlingStrategy":"validation","validationCode":"let url = String(image ?? '').trim();\nif (url && !/^https?:\\/\\//i.test(url)) url = 'https://' + url;\ntry { new URL(url); } catch { throw new Error(`image is not a valid URL: ${image}`); }","typeGuard":"function isHttpUrl(v) {\n  if (typeof v !== 'string') return false;\n  try { const u = new URL(v); return u.protocol === 'http:' || u.protocol === 'https:'; }\n  catch { return false; }\n}","tryCatchPattern":"try {\n  await cli.pinCreate({ board, image });\n} catch (e) {\n  if (/must be a remote image URL/.test(e.message)) {\n    console.error('got:', e.message.match(/got \"(.*)\"/)?.[1], '— pass a full http(s) URL');\n  } else throw e;\n}","preventionTips":["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"],"tags":["pinterest","invalid-url","invalid-argument","cli"],"backgroundTag":"invalid-url-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}