jackwener/OpenCLI · error · ArgumentError
正文不能超过 1000 字
Error message
正文不能超过 1000 字
What it means
The caption (正文) field is capped at 1000 characters by the draft command. If kwargs.caption (defaulting to '') has .length > 1000, an ArgumentError is thrown before the browser session starts.
Source
Thrown at clis/douyin/draft.js:321
{ name: 'visibility', default: 'public', choices: ['public', 'friends', 'private'] },
],
columns: ['status', 'draft_id'],
func: async (page, kwargs) => {
const videoPath = path.resolve(kwargs.video);
if (!fs.existsSync(videoPath)) {
throw new ArgumentError(`视频文件不存在: ${videoPath}`);
}
const ext = path.extname(videoPath).toLowerCase();
if (!['.mp4', '.mov', '.avi', '.webm'].includes(ext)) {
throw new ArgumentError(`不支持的视频格式: ${ext}(支持 mp4/mov/avi/webm)`);
}
const title = kwargs.title;
if (title.length > 30) {
throw new ArgumentError('标题不能超过 30 字');
}
const caption = kwargs.caption || '';
if (caption.length > 1000) {
throw new ArgumentError('正文不能超过 1000 字');
}
const coverPath = kwargs.cover;
if (coverPath) {
if (!fs.existsSync(path.resolve(coverPath))) {
throw new ArgumentError(`封面文件不存在: ${path.resolve(coverPath)}`);
}
}
if (!page.setFileInput) {
throw new CommandExecutionError('当前浏览器适配器不支持文件注入', '请使用 Browser Bridge 或支持 setFileInput 的浏览器模式');
}
const visibilityLabel = VISIBILITY_LABELS[kwargs.visibility] ?? VISIBILITY_LABELS.public;
await page.goto(DRAFT_UPLOAD_URL);
await page.wait({ selector: 'input[type="file"]', timeout: 20 });
await dismissKnownModals(page);
await page.setFileInput([videoPath], 'input[type="file"]');
await waitForDraftComposer(page);
await dismissKnownModals(page);
if (coverPath) {View on GitHub (pinned to 49907e53dc)
Solutions
- Shorten the caption to ≤1000 characters
- Truncate in code before calling: `[...caption].slice(0, 1000).join('')`
- Move long-form content into the video itself or a pinned comment instead of the caption
Example fix
// before
const caption = longDescription; // 1500 chars
// after
const caption = [...longDescription].slice(0, 1000).join(''); Defensive patterns
Strategy: validation
Validate before calling
if ([...caption].length > 1000) throw new Error('Caption exceeds 1000-char Douyin limit'); Try / catch
try {
await cli.draft({ caption, video, title });
} catch (e) {
if (e instanceof ArgumentError && e.message.includes('正文不能超过')) {
await cli.draft({ caption: [...caption].slice(0, 1000).join(''), video, title });
} else throw e;
} Prevention
- Truncate cross-posted descriptions to 1000 chars before calling
- Move long-form content to a pinned comment or the video itself
- Count with [...str].length to handle emoji/surrogate pairs correctly
When it happens
Trigger: Passing --caption or caption kwarg with more than 1000 characters — long descriptions, pasted articles, many hashtags and mentions concatenated.
Common situations: Cross-posting long-form descriptions from other platforms, programmatically generated captions with repeated hashtag blocks, or template expansion blowing past the cap.
Related errors
- 标题不能超过 30 字
- ${name} must be <= ${max}
- pubmed ${label} must be <= ${maxValue}
- archive search sort must be one of ${SORT_OPTIONS.join(', ')
- archive search mediatype must be one of ${MEDIATYPES.join(',
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/9fc3b48697547947.
Report an issue: GitHub.