{"record":{"id":"40a791fb3ba3fee7","repo":"jackwener/OpenCLI","slug":"videopath","errorCode":null,"errorMessage":"视频文件不存在: ${videoPath}","messagePattern":"视频文件不存在: (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/douyin/draft.js","lineNumber":309,"sourceCode":"    site: 'douyin',\n    name: 'draft',\n    access: 'write',\n    description: '上传视频并保存为草稿',\n    domain: 'creator.douyin.com',\n    strategy: Strategy.COOKIE,\n    navigateBefore: false,\n    args: [\n        { name: 'video', required: true, positional: true, help: '视频文件路径' },\n        { name: 'title', required: true, help: '视频标题（≤30字）' },\n        { name: 'caption', default: '', help: '正文内容（≤1000字，支持 #话题）' },\n        { name: 'cover', default: '', help: '封面图片路径' },\n        { name: 'visibility', default: 'public', choices: ['public', 'friends', 'private'] },\n    ],\n    columns: ['status', 'draft_id'],\n    func: async (page, kwargs) => {\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 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 coverPath = kwargs.cover;\n        if (coverPath) {\n            if (!fs.existsSync(path.resolve(coverPath))) {\n                throw new ArgumentError(`封面文件不存在: ${path.resolve(coverPath)}`);\n            }","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/douyin/draft.js#L291-L327","documentation":"Before touching the browser, the draft CLI's func resolves --video to an absolute path and checks fs.existsSync. If the file does not exist it throws an ArgumentError with the resolved path in the message. This is an immediate input-validation failure, not a browser error.","triggerScenarios":"Passing a --video path that is misspelled, relative to the wrong working directory, deleted before the run, or a directory instead of a file.","commonSituations":"Running the CLI from a different cwd than expected with a relative path; file on an unmounted drive/network share; shell quoting issues splitting the path; typo in the filename or extension case mismatch on case-sensitive filesystems.","solutions":["Check the path printed in the error and verify it with ls; pass an absolute path or run from the correct directory","Confirm the file exists and is readable by the user running the CLI","Quote the path in your shell if it contains spaces"],"exampleFix":"// before\nopencli douyin draft ./my video.mp4 --title t   # path split by space\n// after\nopencli douyin draft \"/absolute/path/my video.mp4\" --title t","handlingStrategy":"validation","validationCode":"const videoPath = path.resolve(kwargs.video);\nif (!fs.existsSync(videoPath)) {\n  throw new Error(`视频文件不存在: ${videoPath}`);\n}\nif (!fs.statSync(videoPath).isFile()) {\n  throw new Error(`不是文件: ${videoPath}`);\n}","typeGuard":"function isExistingFile(p) {\n  try { return fs.statSync(p).isFile(); } catch { return false; }\n}\nif (!isExistingFile(path.resolve(video))) throw new Error(`视频文件不存在: ${video}`);","tryCatchPattern":"// ArgumentError is thrown before any browser action — validate inputs up front\n// rather than catching; wrap only for friendly CLI output:\ntry {\n  await opencli.douyin.draft({ video, title });\n} catch (e) {\n  if (e.message.startsWith('视频文件不存在')) {\n    console.error('Check the --video path and your working directory:', e.message);\n  }\n}","preventionTips":["Always pass absolute paths for --video","Quote paths containing spaces in your shell","Verify the file exists (ls) before running the command","Remember paths resolve against the CLI process cwd, not your shell's expectations if run via a wrapper"],"tags":["argument-error","file-not-found","input-validation","douyin"],"backgroundTag":"file-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}