jackwener/OpenCLI · error · ArgumentError

comment text must be <= ${COMMENT_TEXT_MAX} characters (got

Error message

comment text must be <= ${COMMENT_TEXT_MAX} characters (got ${text.length})

What it means

requireCommentText validates the comment body passed to TikTok comment commands. TikTok enforces a maximum comment length (COMMENT_TEXT_MAX) and rejects long comments at submit time, so the CLI pre-checks and throws an ArgumentError before any network call.

Source

Thrown at clis/tiktok/utils.js:91

    }
    return key;
}

// Comment text bound: TikTok rejects long comments at submit time.
// We validate length + non-empty up-front so the adapter never tries to
// paste an empty / overlong string into the contenteditable input.
export const COMMENT_TEXT_MAX = 150;

export function requireCommentText(value) {
    const text = String(value ?? '').trim();
    if (!text) {
        throw new ArgumentError(
            'comment text is required',
            'Example: opencli tiktok comment <url> "great video"',
        );
    }
    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 "..."',

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Count your comment length (text.length) and trim it to COMMENT_TEXT_MAX characters
  2. Shorten or split the message; TikTok rejects long comments server-side anyway
  3. If the text comes from a file or variable, pre-trim it with .slice(0, COMMENT_TEXT_MAX) before invoking the command

Example fix

// before
opencli tiktok comment https://www.tiktok.com/@user/video/123 "<2000-char text>"
// after
opencli tiktok comment https://www.tiktok.com/@user/video/123 "$(head -c 150 comment.txt)"
Defensive patterns

Strategy: validation

Validate before calling

if (typeof text !== 'string' || text.length > COMMENT_TEXT_MAX) throw new Error(`comment must be <= ${COMMENT_TEXT_MAX} chars, got ${text?.length}`);

Type guard

const isShortEnough = (t) => typeof t === 'string' && t.length <= COMMENT_TEXT_MAX;

Try / catch

try { cli.comment(url, text); } catch (e) { if (/comment text must be <=/.test(e.message)) console.error('Trim your comment to', COMMENT_TEXT_MAX, 'chars'); else throw e; }

Prevention

When it happens

Trigger: Calling opencli tiktok comment (or the text() helper) with a comment string whose text.length exceeds COMMENT_TEXT_MAX.

Common situations: Pasting multi-paragraph text into the CLI; scripts interpolating long templates into the comment argument; forgetting that emoji/spaces count toward the limit.

Related errors


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