jackwener/OpenCLI · error · CommandExecutionError

Failed to fill summary

Error message

Failed to fill summary

What it means

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.

Source

Thrown at clis/weixin/create-draft.js:316

            if (!titleResult?.ok) throw new CommandExecutionError('Failed to fill title');
            if (kwargs.author) {
                const authorResult = await fillField(page, 'input#author', kwargs.author);
                if (!authorResult?.ok) throw new CommandExecutionError('Failed to fill author');
            }
            const contentResult = await fillContent(page, kwargs.content);
            if (!contentResult?.ok) throw new CommandExecutionError('Failed to fill content');

            if (coverImage) {
                await uploadContentImage(page, coverImage);
                const coverSet = await selectCoverFromContent(page);
                if (coverSet !== true) {
                    throw new CommandExecutionError('WeChat uploaded the image but did not confirm it as the draft cover.');
                }
            }

            if (kwargs.summary) {
                const summaryResult = await fillField(page, 'textarea#js_description', kwargs.summary);
                if (!summaryResult?.ok) throw new CommandExecutionError('Failed to fill summary');
            }

            await saveDraft(page);
            return [{
                status: 'draft saved',
                detail: `"${kwargs.title}"${kwargs.author ? ` by ${kwargs.author}` : ''}${coverImage ? ' (with cover)' : ''}`,
            }];
        } catch (error) {
            if (error instanceof CliError) throw error;
            const message = error instanceof Error ? error.message : String(error);
            throw new CommandExecutionError(`WeChat create-draft failed: ${message}`);
        }
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry the command — transient render timing past fixed waits is the most common cause.
  2. 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.
  3. Add an explicit wait (or a click to expand the summary section) for textarea#js_description before calling fillField.
  4. Omit --summary temporarily to complete draft creation, then set the digest manually in the WeChat UI.

Example fix

// before
const summaryResult = await fillField(page, 'textarea#js_description', kwargs.summary);
if (!summaryResult?.ok) throw new CommandExecutionError('Failed to fill summary');
// after
await page.waitForSelector('textarea#js_description', { timeout: 10000 }).catch(() => {});
const summaryResult = await fillField(page, 'textarea#js_description', kwargs.summary);
if (!summaryResult?.ok) throw new CommandExecutionError('Failed to fill summary: ' + (summaryResult?.reason ?? 'unknown'));
Defensive patterns

Strategy: fallback

Validate before calling

const hasSummary = await page.evaluate('!!document.querySelector("textarea#js_description")');
if (kwargs.summary && hasSummary !== true) console.warn('Summary field missing; draft will be created without a digest.');

Try / catch

try {
  await createDraft({ title, content, summary });
} catch (e) {
  if (e instanceof CommandExecutionError && /Failed to fill summary/.test(e.message)) {
    // degrade: retry without summary, or set the digest manually in the WeChat UI
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/e4c5baa5025c1342. Report an issue: GitHub.