{"record":{"id":"de5124dffbf148e9","repo":"jackwener/OpenCLI","slug":"videopath-de5124","errorCode":null,"errorMessage":"视频文件不存在: ${videoPath}","messagePattern":"视频文件不存在: (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/douyin/publish.js","lineNumber":115,"sourceCode":"        { name: 'schedule', required: true, help: '定时发布时间（ISO8601 或 Unix 秒，2h ~ 14天后）' },\n        { name: 'caption', default: '', help: '正文内容（≤1000字，支持 #话题）' },\n        { name: 'cover', default: '', help: '封面图片路径（不提供时使用视频截帧）' },\n        { name: 'visibility', default: 'public', choices: ['public', 'friends', 'private'] },\n        { name: 'allow_download', type: 'bool', default: false, help: '允许下载' },\n        { name: 'collection', default: '', help: '合集 ID' },\n        { name: 'activity', default: '', help: '活动 ID' },\n        { name: 'poi_id', default: '', help: '地理位置 ID' },\n        { name: 'poi_name', default: '', help: '地理位置名称' },\n        { name: 'hotspot', default: '', help: '关联热点词' },\n        { name: 'no_safety_check', type: 'bool', default: false, help: '跳过内容安全检测' },\n        { name: 'sync_toutiao', type: 'bool', default: false, help: '同步发布到头条' },\n    ],\n    columns: ['status', 'aweme_id', 'url', 'publish_time'],\n    func: async (page, kwargs) => {\n        // ── Fail-fast validation ────────────────────────────────────────────\n        const videoPath = path.resolve(kwargs.video);\n        if (!fs.existsSync(videoPath)) {\n            throw new ArgumentError(`视频文件不存在: ${videoPath}`);\n        }\n        const ext = path.extname(videoPath).toLowerCase();\n        if (!['.mp4', '.mov', '.avi', '.webm'].includes(ext)) {\n            throw new ArgumentError(`不支持的视频格式: ${ext}（支持 mp4/mov/avi/webm）`);\n        }\n        const fileSize = fs.statSync(videoPath).size;\n        const title = kwargs.title;\n        if (title.length > 30) {\n            throw new ArgumentError('标题不能超过 30 字');\n        }\n        const caption = kwargs.caption || '';\n        if (caption.length > 1000) {\n            throw new ArgumentError('正文不能超过 1000 字');\n        }\n        const timingTs = toUnixSeconds(kwargs.schedule);\n        validateTiming(timingTs);\n        const visibilityType = VISIBILITY_MAP[kwargs.visibility] ?? 0;\n        const coverPath = kwargs.cover;","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/douyin/publish.js#L97-L133","documentation":"ArgumentError thrown during the publish command's fail-fast validation when the resolved video path does not exist on disk (fs.existsSync fails after path.resolve).","triggerScenarios":"kwargs.video points to a missing file: wrong path, relative path resolved from an unexpected cwd, file deleted/moved before publish (clis/douyin/publish.js:115).","commonSituations":"Relative paths in scripts run from a different directory; typos in the filename; video not yet rendered by an upstream pipeline step; Windows/Unix path separator confusion.","solutions":["Pass an absolute path (or path.resolve the path yourself before calling).","Verify the file exists: ls the exact resolved path shown in the error message.","Run the command from the directory you expect (cwd matters for relative paths).","Ensure the upstream render/encode step completed before publishing."],"exampleFix":"// before\nopencli douyin publish --video ./out/final.mp4\n// after\nopencli douyin publish --video \"$(pwd)/out/final.mp4\"","handlingStrategy":"validation","validationCode":"const videoPath = path.resolve(kwargs.video);\nif (!fs.existsSync(videoPath)) {\n  throw new Error(`video file not found: ${videoPath} (cwd=${process.cwd()})`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await publish({ video: videoPath, title });\n} catch (e) {\n  if (String(e.message).startsWith('视频文件不存在')) {\n    console.error('check the resolved path in the message; cwd may differ from expectation');\n  }\n  throw e;\n}","preventionTips":["Always pass absolute paths to publish.","Assert file existence in pipeline scripts before invoking the CLI.","Ensure upstream render steps finish (and fsync/close) before publishing.","Be careful with relative paths in cron/scheduled jobs where cwd differs."],"tags":["filesystem","argument-validation","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}