jackwener/OpenCLI · error · ArgumentError

video URL is required

Error message

video URL is required

What it means

parseTikTokVideoUrl requires a non-empty canonical TikTok video URL. After trimming and String-coercion, an empty value means there is nothing to parse, so an ArgumentError with a usage example is thrown.

Source

Thrown at clis/tiktok/utils.js:107

    }
    if (text.length > COMMENT_TEXT_MAX) {
        throw new ArgumentError(
            `comment text must be <= ${COMMENT_TEXT_MAX} characters (got ${text.length})`,
            'TikTok rejects long comments at submit time; trim before retrying',
        );
    }
    return text;
}

// Parses a TikTok video URL into {username, videoId, url}. Rejects bad
// shapes up-front so we never `goto()` an arbitrary page and silently
// pretend the click target was found. Both share-style links
// (vm.tiktok.com/...) and bare video IDs are out of scope — callers must
// pass the canonical /@user/video/id form.
export function parseTikTokVideoUrl(value) {
    const raw = String(value ?? '').trim();
    if (!raw) {
        throw new ArgumentError(
            'video URL is required',
            'Example: opencli tiktok comment https://www.tiktok.com/@user/video/1234567890 "..."',
        );
    }
    let parsed;
    try {
        parsed = new URL(raw);
    } catch {
        throw new ArgumentError(
            `invalid video URL: ${raw}`,
            'Example: https://www.tiktok.com/@user/video/1234567890',
        );
    }
    if (!/(^|\.)tiktok\.com$/i.test(parsed.hostname)) {
        throw new ArgumentError(
            `URL must be on tiktok.com (got ${parsed.hostname})`,
            'Example: https://www.tiktok.com/@user/video/1234567890',
        );

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass a canonical URL: opencli tiktok comment https://www.tiktok.com/@user/video/1234567890 "..."
  2. Check that the shell variable holding the URL is actually set (echo "$URL")
  3. Ensure the URL comes before the comment text in argument order so it is not consumed elsewhere

Example fix

// before
parseTikTokVideoUrl(opts.url) // opts.url undefined
// after
if (!opts.url) throw new Error('--url is required');
parseTikTokVideoUrl(opts.url)
Defensive patterns

Strategy: validation

Validate before calling

if (!url || !String(url).trim()) throw new Error('URL argument is required');

Type guard

const hasUrl = (u) => typeof u === 'string' && u.trim().length > 0;

Try / catch

try { parseTikTokVideoUrl(url); } catch (e) { if (/video URL is required/.test(e.message)) console.error('Pass e.g. https://www.tiktok.com/@user/video/123'); else throw e; }

Prevention

When it happens

Trigger: Calling parseTikTokVideoUrl with '', null, undefined, whitespace, or any value that coerces to an empty string (e.g. String(value ?? '').trim() === '').

Common situations: CLI invoked without the URL argument; shell variable unset or empty ($URL expanded to nothing); a prior extraction step returned null/undefined.

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/f98db2dc9f0bce71. Report an issue: GitHub.