{"record":{"id":"89f64883ca23369d","repo":"jackwener/OpenCLI","slug":"reschedule-caption","errorCode":null,"errorMessage":"必须提供 --reschedule 或 --caption","messagePattern":"必须提供 --reschedule 或 --caption","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/douyin/update.js","lineNumber":20,"sourceCode":"import { ArgumentError } from '@jackwener/opencli/errors';\nimport { browserFetch } from './_shared/browser-fetch.js';\nimport { toUnixSeconds, validateTiming } from './_shared/timing.js';\ncli({\n    site: 'douyin',\n    name: 'update',\n    access: 'write',\n    description: '更新视频信息',\n    domain: 'creator.douyin.com',\n    strategy: Strategy.COOKIE,\n    args: [\n        { name: 'aweme_id', required: true, positional: true, help: '抖音作品 ID（aweme_id，可从作品 URL 末尾获取）' },\n        { name: 'reschedule', default: '', help: '新的发布时间（ISO8601 或 Unix 秒）' },\n        { name: 'caption', default: '', help: '新的正文内容' },\n    ],\n    columns: ['status'],\n    func: async (page, kwargs) => {\n        if (!kwargs.reschedule && !kwargs.caption) {\n            throw new ArgumentError('必须提供 --reschedule 或 --caption');\n        }\n        if (kwargs.reschedule) {\n            const newTime = toUnixSeconds(kwargs.reschedule);\n            validateTiming(newTime);\n            await browserFetch(page, 'POST', 'https://creator.douyin.com/web/api/media/update/timer/?aid=1128', { body: { aweme_id: kwargs.aweme_id, publish_time: newTime } });\n        }\n        if (kwargs.caption) {\n            await browserFetch(page, 'POST', 'https://creator.douyin.com/web/api/media/update/desc/?aid=1128', { body: { aweme_id: kwargs.aweme_id, desc: kwargs.caption } });\n        }\n        return [{ status: '✅ 更新成功' }];\n    },\n});\n","sourceCodeStart":2,"sourceCodeEnd":33,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/douyin/update.js#L2-L33","documentation":"An ArgumentError thrown by the douyin update command when neither --reschedule nor --caption is provided. The command performs exactly one of: rescheduling the publish time via the media/update/timer API, or rewriting the caption text. With no operation specified there is nothing to do, so the library fails fast instead of issuing a no-op request.","triggerScenarios":"Calling `douyin update --aweme-id <id>` with no --reschedule and no --caption flag (or with both flags present but empty strings, which is their default '').","commonSituations":"Scripted invocations that build the argument list dynamically and drop empty flags; calling the command just to 'touch' a work; forgetting that aweme_id alone does not imply any action.","solutions":["Pass --caption with the new body text, e.g. `douyin update --aweme-id <id> --caption \"new text\"`.","Pass --reschedule with an ISO8601 timestamp or Unix seconds, e.g. `--reschedule \"2026-09-01T10:00:00+08:00\"`.","In scripts, only invoke the update command when at least one of the two values is non-empty."],"exampleFix":"// before\nawait run(['douyin', 'update', '--aweme-id', id]);\n// after\nawait run(['douyin', 'update', '--aweme-id', id, '--caption', newCaption]);","handlingStrategy":"validation","validationCode":"if (!reschedule && !caption) {\n  throw new Error('douyin update requires --reschedule or --caption');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await run('douyin update', { aweme_id: id, caption, reschedule });\n} catch (e) {\n  if (e.name === 'ArgumentError') {\n    console.error('Provide --reschedule or --caption');\n    process.exitCode = 2;\n    return;\n  }\n  throw e;\n}","preventionTips":["In wrappers, drop empty-string flags but assert at least one operation value is present before invoking.","Validate caption is a non-empty string and reschedule parses as ISO8601/Unix seconds before calling.","Never call update with aweme_id alone — it performs nothing by design."],"tags":["argument-error","douyin","cli-usage","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}