{"record":{"id":"0cea5c3247f3f360","repo":"jackwener/OpenCLI","slug":"error-0cea5c","errorCode":null,"errorMessage":"当前浏览器适配器不支持文件注入","messagePattern":"当前浏览器适配器不支持文件注入","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/douyin/draft.js","lineNumber":330,"sourceCode":"        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            }\n        }\n        if (!page.setFileInput) {\n            throw new CommandExecutionError('当前浏览器适配器不支持文件注入', '请使用 Browser Bridge 或支持 setFileInput 的浏览器模式');\n        }\n        const visibilityLabel = VISIBILITY_LABELS[kwargs.visibility] ?? VISIBILITY_LABELS.public;\n        await page.goto(DRAFT_UPLOAD_URL);\n        await page.wait({ selector: 'input[type=\"file\"]', timeout: 20 });\n        await dismissKnownModals(page);\n        await page.setFileInput([videoPath], 'input[type=\"file\"]');\n        await waitForDraftComposer(page);\n        await dismissKnownModals(page);\n        if (coverPath) {\n            const coverSelector = await prepareCustomCoverInput(page);\n            await page.setFileInput([path.resolve(coverPath)], coverSelector);\n            await waitForCoverReady(page);\n        }\n        await fillDraftComposer(page, { title, caption, visibilityLabel });\n        await page.wait({ time: 1 });\n        const saveResult = await clickSaveDraft(page);\n        const draftId = await waitForDraftResult(page, saveResult.creationId);\n        return [","sourceCodeStart":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/douyin/draft.js#L312-L348","documentation":"The draft flow injects the video file directly into the page's <input type=file> via page.setFileInput. If the current browser adapter does not implement setFileInput, a CommandExecutionError is thrown telling the user to switch to Browser Bridge or another adapter that supports file injection.","triggerScenarios":"Running `douyin draft` while connected through a browser adapter lacking setFileInput — e.g. a remote/CDP-attached page object, a limited driver, or an adapter version predating the setFileInput API.","commonSituations":"Using a remote browser session/Bridge-less mode, older adapter versions, connecting to an already-running Chrome via plain CDP, or swapping the default browser backend in config.","solutions":["Switch to the Browser Bridge adapter (or any mode supporting setFileInput) as the error message advises","Upgrade the browser adapter/driver package to a version that implements setFileInput","Check for the capability before running: `if (!page.setFileInput) { /* switch adapter */ }`"],"exampleFix":"// before\nconst page = await connect({ mode: 'cdp-attach' }); // no setFileInput\n// after\nconst page = await connect({ mode: 'browser-bridge' }); // supports setFileInput","handlingStrategy":"fallback","validationCode":"if (typeof page.setFileInput !== 'function') {\n  console.error('Adapter lacks setFileInput — reconnect with Browser Bridge');\n  process.exit(1);\n}","typeGuard":"const supportsFileInput = (page) => typeof page?.setFileInput === 'function';","tryCatchPattern":"try {\n  await cli.draft({ video, title });\n} catch (e) {\n  if (e instanceof CommandExecutionError && e.message.includes('不支持文件注入')) {\n    const page = await connect({ mode: 'browser-bridge' });\n    await cli.draft({ video, title }, { page });\n  } else throw e;\n}","preventionTips":["Use the Browser Bridge adapter for any flow that uploads files","Keep the browser adapter package updated so setFileInput is available","Feature-check page.setFileInput at startup before long automation runs"],"tags":["browser-automation","capability-missing","command-execution-error"],"backgroundTag":"unsupported-browser-capability","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}