jackwener/OpenCLI · error · ArgumentError

正文不能超过 1000 字

Error message

正文不能超过 1000 字

What it means

The douyin publish command validates the video caption (正文) length before starting the browser publish flow. Douyin caps captions at 1000 characters, so publish.js throws this ArgumentError pre-flight to avoid a rejected submission later in the platform's create_v2 call. It fails fast before any upload work happens.

Source

Thrown at clis/douyin/publish.js:128

    columns: ['status', 'aweme_id', 'url', 'publish_time'],
    func: async (page, kwargs) => {
        // ── Fail-fast validation ────────────────────────────────────────────
        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 fileSize = fs.statSync(videoPath).size;
        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 timingTs = toUnixSeconds(kwargs.schedule);
        validateTiming(timingTs);
        const visibilityType = VISIBILITY_MAP[kwargs.visibility] ?? 0;
        const coverPath = kwargs.cover;
        if (coverPath) {
            if (!fs.existsSync(path.resolve(coverPath))) {
                throw new ArgumentError(`封面文件不存在: ${path.resolve(coverPath)}`);
            }
        }
        // ── Phase 1: upload credentials ────────────────────────────────────
        const credentials = await getUploadAuthV5Credentials(page);
        // ── Phase 2: Apply TOS upload URL ───────────────────────────────────
        const tosUploadInfo = await applyVideoUploadInner(fileSize, credentials);
        let coverUri = '';
        let coverWidth = 720;
        let coverHeight = 1280;
        // ── Phase 3: TOS upload ─────────────────────────────────────────────

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Shorten the caption to 1000 characters or fewer before invoking publish
  2. Trim programmatically: caption.slice(0, 1000) or move excess text into hashtags/description fields
  3. Check caption.length before calling the command and surface a client-side validation message

Example fix

// before
await douyin.publish({ title: 'My video', caption: longCaption });
// after
const caption = longCaption.length > 1000 ? longCaption.slice(0, 1000) : longCaption;
await douyin.publish({ title: 'My video', caption });
Defensive patterns

Strategy: validation

Validate before calling

const caption = kwargs.caption ?? '';
if (typeof caption !== 'string' || caption.length > 1000) {
  throw new Error(`caption must be a string of at most 1000 chars, got ${caption.length}`);
}

Type guard

function isValidCaption(v) {
  return typeof v === 'string' && v.length <= 1000;
}

Try / catch

try {
  await douyin.publish({ title, caption });
} catch (e) {
  if (e instanceof ArgumentError && /正文不能超过/.test(e.message)) {
    caption = caption.slice(0, 1000);
    await douyin.publish({ title, caption });
  } else throw e;
}

Prevention

When it happens

Trigger: Calling the douyin publish command with kwargs.caption (or the caption CLI flag) set to a string whose .length exceeds 1000; no upload or browser interaction occurs — the throw is at the very start of the command.

Common situations: Users paste long video descriptions, marketing copy, or transcripts as the caption; content generated from templates that don't account for the 1000-char cap; non-ASCII text where users misjudge counts.

Related errors


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