jackwener/OpenCLI · error · CommandExecutionError

`Failed to inspect GeoGebra object: ${exists.error}`

Error message

`Failed to inspect GeoGebra object: ${exists.error}`

What it means

Thrown when the probe succeeded structurally but the in-page script reported an error in its envelope ({error: '...'}) — most commonly 'ggbApplet is not ready', or an exception thrown by ggbApplet.getObjectType inside the page. The library surfaces it as a CommandExecutionError prefixed with 'Failed to inspect GeoGebra object'.

Source

Thrown at clis/geogebra/info.js:45

          try {
            if (typeof ggbApplet === 'undefined' || typeof ggbApplet.getObjectType !== 'function') {
              return { error: 'ggbApplet is not ready' };
            }
            return { ok: true, exists: ggbApplet.getObjectType(name) !== '' };
          } catch (err) {
            return { error: err?.message || String(err) };
          }
        })
        (${JSON.stringify(objName)})
      `));
    } catch (err) {
      throw new CommandExecutionError(`Failed to inspect GeoGebra object: ${err?.message || err}`);
    }
    if (!exists || typeof exists !== 'object' || Array.isArray(exists)) {
      throw new CommandExecutionError('GeoGebra object existence probe returned malformed result');
    }
    if (exists.error) {
      throw new CommandExecutionError(`Failed to inspect GeoGebra object: ${exists.error}`);
    }
    if (exists.ok !== true || typeof exists.exists !== 'boolean') {
      throw new CommandExecutionError('GeoGebra object existence probe returned malformed result');
    }
    if (exists.exists === false) {
      throw new EmptyResultError(`geogebra info ${objName}`, `Object "${objName}" not found on the canvas.`);
    }

    const properties = ['type', 'value', 'definition', 'command', 'caption', 'visible', 'color'];
    const rows = [];
    for (const prop of properties) {
      const val = await ggbGetProperty(page, objName, prop);
      rows.push({ property: prop, value: String(val ?? '') });
    }

    // For point-like objects, also include coordinates
    const objType = await ggbGetProperty(page, objName, 'type');
    if (objType === 'point') {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Wait a moment and retry so the applet finishes initializing
  2. Run a `geogebra eval` command first to force ensureApplet to wait for ggbApplet readiness
  3. Verify the page is an official GeoGebra applet page (geometry/graphing) where the global is ggbApplet
  4. Read the appended exists.error text — 'ggbApplet is not ready' means timing; other text points to the in-page cause

Example fix

// before
opencli geogebra info --name A   # 'ggbApplet is not ready' right after navigate
// after
opencli geogebra eval --code '1+1'   # waits for applet
opencli geogebra info --name A
Defensive patterns

Strategy: retry

Validate before calling

// wait-for-applet pre-check before info
await run('geogebra', 'eval', '--code', '1+1'); // forces ensureApplet/ggbApplet readiness

Try / catch

try {
  await run('geogebra', 'info', '--name', 'A');
} catch (err) {
  if (/ggbApplet is not ready/.test(err.message)) {
    await sleep(1500);
    return retry(2);
  }
  throw err;
}

Prevention

When it happens

Trigger: `geogebra info --name X` before the applet global (ggbApplet) exists or lacks getObjectType; or getObjectType throws for the given name (e.g. injection/serialization issue in the page context).

Common situations: Running info immediately after navigation before the applet finishes booting; using a GeoGebra page variant that names the API object differently; applet still loading on slow networks.

Related errors


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