jackwener/OpenCLI · error · ArgumentError

shot is required (numeric id or dribbble.com/shots URL)

Error message

shot is required (numeric id or dribbble.com/shots URL)

What it means

requireShotTarget validates the shot argument, accepting either a numeric shot id or a dribbble.com/shots URL. This ArgumentError is thrown when the value is missing or blank after String coercion and trim. Without a shot target no shot lookup can be built.

Source

Thrown at clis/dribbble/utils.js:50

export function optionalQuery(value, label = 'query') {
    const query = String(value ?? '').trim();
    if (query.length > 100) throw new ArgumentError(`${label} must be <= 100 characters`);
    return query;
}

export function requireDesigner(value) {
    const designer = String(value ?? '').trim();
    if (!designer) throw new ArgumentError('designer is required (for example: halolab)');
    if (!/^[A-Za-z0-9_-]{1,100}$/.test(designer)) {
        throw new ArgumentError('designer must be a Dribbble username or profile slug');
    }
    return designer;
}

export function requireShotTarget(value) {
    const target = String(value ?? '').trim();
    if (!target) throw new ArgumentError('shot is required (numeric id or dribbble.com/shots URL)');
    if (/^\d+$/.test(target)) return target;

    let url;
    try {
        url = new URL(target);
    } catch {
        throw new ArgumentError('shot must be a numeric id or dribbble.com/shots URL');
    }
    if (!/(^|\.)dribbble\.com$/i.test(url.hostname)) {
        throw new ArgumentError('shot URL must use dribbble.com');
    }
    const match = url.pathname.match(/^\/shots\/(\d+)(?:-|\/|$)/);
    if (!match) throw new ArgumentError('shot URL must match dribbble.com/shots/<id>');
    return match[1];
}

export function requireRows(payload, command) {
    if (!payload || typeof payload !== 'object') {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Supply a numeric shot id (e.g. '1234567') or a full dribbble.com/shots URL.
  2. Verify the input source (CLI flag, env var, loop variable) actually contains the id.
  3. Guard batch scripts: skip or log rows whose shot field is empty instead of passing '' through.

Example fix

// before
const rows = items.map(i => cli.shot({ shot: i.shotId })); // some shotId are ''

// after
const rows = items.filter(i => i.shotId && String(i.shotId).trim()).map(i => cli.shot({ shot: i.shotId }));
Defensive patterns

Strategy: validation

Validate before calling

const shot = value == null ? '' : String(value).trim();
if (!shot) throw new Error('shot is required: numeric id or dribbble.com/shots URL');

Type guard

function hasShotTarget(v) {
  return v != null && String(v).trim().length > 0;
}

Try / catch

try {
  const result = command({ shot });
} catch (e) {
  if (e instanceof ArgumentError && /shot is required/.test(e.message)) {
    console.error('No shot id/URL provided; pass 1234567 or https://dribbble.com/shots/1234567');
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling a shot command (via `shotId` -> requireShotTarget) with undefined/null, '', a whitespace-only string, or a value coercing to an empty string.

Common situations: Omitting the shot id on the CLI, an empty cell in a spreadsheet/batch script feeding shot ids, or a variable left undefined because a previous extraction step failed silently.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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