jackwener/OpenCLI · error · CommandExecutionError

Gemini generation probe returned a malformed result

Error message

Gemini generation probe returned a malformed result

What it means

Thrown by isGeminiGenerating when the generation probe evaluates successfully but unwrapGeminiEvaluateResult yields a value that is not a boolean. The probe must return true/false for 'is the model generating'; any other shape (undefined, object, string) is rejected so callers can trust the flag.

Source

Thrown at clis/gemini/utils.js:2383

    const urls = requireGeminiArrayResult(result, 'Gemini image detection');
    if (!urls.every((url) => typeof url === 'string')) {
        throw new CommandExecutionError('Gemini image detection returned a malformed result');
    }
    return urls;
}
/** Cheap generation probe: the snapshot read walks the whole transcript. */
export async function isGeminiGenerating(page) {
    let result;
    try {
        result = await page.evaluate(`(() => ${isGeneratingExpression()})()`);
    }
    catch (error) {
        const message = error instanceof Error ? error.message : String(error);
        throw new CommandExecutionError('Gemini generation probe failed', message);
    }
    const value = unwrapGeminiEvaluateResult(result, 'Gemini generation probe');
    if (typeof value !== 'boolean') {
        throw new CommandExecutionError('Gemini generation probe returned a malformed result');
    }
    return value;
}
export async function waitForGeminiImages(page, beforeUrls, timeoutSeconds) {
    const beforeSet = new Set(beforeUrls);
    const pollIntervalSeconds = 3;
    const maxPolls = Math.max(1, Math.ceil(timeoutSeconds / pollIntervalSeconds));
    let lastUrls = [];
    let stableCount = 0;
    let stillGenerating = false;
    for (let index = 0; index < maxPolls; index += 1) {
        await page.wait(index === 0 ? 2 : pollIntervalSeconds);
        // The text waits already gate on this signal; without it the image wait
        // can settle on whatever is on screen mid-generation (#2245). An
        // unreadable probe keeps the last known state so the deadline still
        // reports the right typed error.
        const generating = await isGeminiGenerating(page);
        if (generating !== null)

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Log the raw probe value and update isGeneratingExpression to match the current generating-indicator DOM (return false as default when absent).
  2. Retry the probe once — a mid-render state can transiently yield undefined.
  3. Use readGeminiSnapshot's isGenerating (validated boolean) as an alternative probe.
  4. Catch CommandExecutionError around isGeminiGenerating in polling loops and treat unknown states as 'still waiting'.
Defensive patterns

Strategy: type-guard

Type guard

function isBoolean(v) { return typeof v === 'boolean'; }

Try / catch

let generating = null;
try {
  generating = await isGeminiGenerating(page);
} catch (e) {
  if (String(e.message).includes('malformed result')) generating = null; // unknown state
  else throw e;
}
if (generating !== false) { /* keep waiting */ }

Prevention

When it happens

Trigger: The in-page isGeneratingExpression returns undefined (selector for the generating indicator not found and no fallback), or returns an object/serialized wrapper because the evaluate layer unwraps results differently than expected — typically after a Gemini DOM change to the generating spinner/stop-button area.

Common situations: Gemini redesign replacing the spinner element the probe checks; probe running on a page state (empty chat, error screen) with no indicator at all; evaluate proxy layer wrapping the boolean; stale cached script version in the page.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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