{"record":{"id":"bb604801d084a2ca","repo":"jackwener/OpenCLI","slug":"comment-text-must-be-comment-text-max-charac","errorCode":null,"errorMessage":"comment text must be <= ${COMMENT_TEXT_MAX} characters (got ${text.length})","messagePattern":"comment text must be <= (.+?) characters \\(got (.+?)\\)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/tiktok/utils.js","lineNumber":91,"sourceCode":"    }\n    return key;\n}\n\n// Comment text bound: TikTok rejects long comments at submit time.\n// We validate length + non-empty up-front so the adapter never tries to\n// paste an empty / overlong string into the contenteditable input.\nexport const COMMENT_TEXT_MAX = 150;\n\nexport function requireCommentText(value) {\n    const text = String(value ?? '').trim();\n    if (!text) {\n        throw new ArgumentError(\n            'comment text is required',\n            'Example: opencli tiktok comment <url> \"great video\"',\n        );\n    }\n    if (text.length > COMMENT_TEXT_MAX) {\n        throw new ArgumentError(\n            `comment text must be <= ${COMMENT_TEXT_MAX} characters (got ${text.length})`,\n            'TikTok rejects long comments at submit time; trim before retrying',\n        );\n    }\n    return text;\n}\n\n// Parses a TikTok video URL into {username, videoId, url}. Rejects bad\n// shapes up-front so we never `goto()` an arbitrary page and silently\n// pretend the click target was found. Both share-style links\n// (vm.tiktok.com/...) and bare video IDs are out of scope — callers must\n// pass the canonical /@user/video/id form.\nexport function parseTikTokVideoUrl(value) {\n    const raw = String(value ?? '').trim();\n    if (!raw) {\n        throw new ArgumentError(\n            'video URL is required',\n            'Example: opencli tiktok comment https://www.tiktok.com/@user/video/1234567890 \"...\"',","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/tiktok/utils.js#L73-L109","documentation":"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.","triggerScenarios":"Calling opencli tiktok comment (or the text() helper) with a comment string whose text.length exceeds COMMENT_TEXT_MAX.","commonSituations":"Pasting multi-paragraph text into the CLI; scripts interpolating long templates into the comment argument; forgetting that emoji/spaces count toward the limit.","solutions":["Count your comment length (text.length) and trim it to COMMENT_TEXT_MAX characters","Shorten or split the message; TikTok rejects long comments server-side anyway","If the text comes from a file or variable, pre-trim it with .slice(0, COMMENT_TEXT_MAX) before invoking the command"],"exampleFix":"// before\nopencli tiktok comment https://www.tiktok.com/@user/video/123 \"<2000-char text>\"\n// after\nopencli tiktok comment https://www.tiktok.com/@user/video/123 \"$(head -c 150 comment.txt)\"","handlingStrategy":"validation","validationCode":"if (typeof text !== 'string' || text.length > COMMENT_TEXT_MAX) throw new Error(`comment must be <= ${COMMENT_TEXT_MAX} chars, got ${text?.length}`);","typeGuard":"const isShortEnough = (t) => typeof t === 'string' && t.length <= COMMENT_TEXT_MAX;","tryCatchPattern":"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; }","preventionTips":["Trim/slice user-provided text to COMMENT_TEXT_MAX before calling","Count characters in your shell with ${#text} when passing CLI args","Test comment length limits once per CLI version"],"tags":["validation","input-length","argument-error"],"backgroundTag":"input-length-validation-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}