{"record":{"id":"e4c5baa5025c1342","repo":"jackwener/OpenCLI","slug":"failed-to-fill-summary","errorCode":null,"errorMessage":"Failed to fill summary","messagePattern":"Failed to fill summary","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/weixin/create-draft.js","lineNumber":316,"sourceCode":"            if (!titleResult?.ok) throw new CommandExecutionError('Failed to fill title');\n            if (kwargs.author) {\n                const authorResult = await fillField(page, 'input#author', kwargs.author);\n                if (!authorResult?.ok) throw new CommandExecutionError('Failed to fill author');\n            }\n            const contentResult = await fillContent(page, kwargs.content);\n            if (!contentResult?.ok) throw new CommandExecutionError('Failed to fill content');\n\n            if (coverImage) {\n                await uploadContentImage(page, coverImage);\n                const coverSet = await selectCoverFromContent(page);\n                if (coverSet !== true) {\n                    throw new CommandExecutionError('WeChat uploaded the image but did not confirm it as the draft cover.');\n                }\n            }\n\n            if (kwargs.summary) {\n                const summaryResult = await fillField(page, 'textarea#js_description', kwargs.summary);\n                if (!summaryResult?.ok) throw new CommandExecutionError('Failed to fill summary');\n            }\n\n            await saveDraft(page);\n            return [{\n                status: 'draft saved',\n                detail: `\"${kwargs.title}\"${kwargs.author ? ` by ${kwargs.author}` : ''}${coverImage ? ' (with cover)' : ''}`,\n            }];\n        } catch (error) {\n            if (error instanceof CliError) throw error;\n            const message = error instanceof Error ? error.message : String(error);\n            throw new CommandExecutionError(`WeChat create-draft failed: ${message}`);\n        }\n    },\n});\n","sourceCodeStart":298,"sourceCodeEnd":331,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/weixin/create-draft.js#L298-L331","documentation":"This CommandExecutionError is thrown when the optional summary (digest) step fails: fillField(page, 'textarea#js_description', ...) returned a non-ok result, meaning the summary textarea was not found in the editor DOM. As with the other fill errors, fillField only reports 'field not found'; the command wraps it in this error. It runs only when kwargs.summary was provided.","triggerScenarios":"Running create-draft with --summary while textarea#js_description is absent: WeChat changed the digest field's id, the summary field renders only after certain editor states (e.g., after save or in an expandable section) and the script does not wait for it, or the page served is a variant layout without that id.","commonSituations":"WeChat renames the digest input during an editor redesign; the summary field appears in a collapsed '摘要' section that requires a click to reveal; slow rendering past the fixed waits; account-level feature flags serving an editor without the classic digest textarea.","solutions":["Retry the command — transient render timing past fixed waits is the most common cause.","Inspect the live editor for the digest field's current id/structure and update the 'textarea#js_description' selector in clis/weixin/create-draft.js.","Add an explicit wait (or a click to expand the summary section) for textarea#js_description before calling fillField.","Omit --summary temporarily to complete draft creation, then set the digest manually in the WeChat UI."],"exampleFix":"// before\nconst summaryResult = await fillField(page, 'textarea#js_description', kwargs.summary);\nif (!summaryResult?.ok) throw new CommandExecutionError('Failed to fill summary');\n// after\nawait page.waitForSelector('textarea#js_description', { timeout: 10000 }).catch(() => {});\nconst summaryResult = await fillField(page, 'textarea#js_description', kwargs.summary);\nif (!summaryResult?.ok) throw new CommandExecutionError('Failed to fill summary: ' + (summaryResult?.reason ?? 'unknown'));","handlingStrategy":"fallback","validationCode":"const hasSummary = await page.evaluate('!!document.querySelector(\"textarea#js_description\")');\nif (kwargs.summary && hasSummary !== true) console.warn('Summary field missing; draft will be created without a digest.');","typeGuard":null,"tryCatchPattern":"try {\n  await createDraft({ title, content, summary });\n} catch (e) {\n  if (e instanceof CommandExecutionError && /Failed to fill summary/.test(e.message)) {\n    // degrade: retry without summary, or set the digest manually in the WeChat UI\n  } else throw e;\n}","preventionTips":["Treat summary as optional and omit it when the digest field is known to be missing or relocated.","Confirm the digest textarea id (js_description) after any WeChat editor update.","Retry once — the field may render after the fixed waits.","If the digest sits in a collapsed section, expand it (or wait for the selector) before filling."],"tags":["puppeteer","dom-selector","wechat","automation"],"backgroundTag":"dom-element-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}