jackwener/OpenCLI · error · CommandExecutionError

Failed to read GeoGebra object property: ${err?.message || e

Error message

Failed to read GeoGebra object property: ${err?.message || err}

What it means

ggbGetProperty in clis/geogebra/utils.js wraps every failure of the in-page GeoGebra bridge call (page.evaluate on the ggbApplet API) in a CommandExecutionError with this message. It means the browser-side call to one of the ggbApplet getters (getObjectType, getValueString, getXcoord, etc.) threw, or the bridge envelope failed to unwrap, so the property could not be read. The library throws it because the original browser exception is not serializable/meaningful on the Node side and gets normalized into a single CLI error.

Source

Thrown at clis/geogebra/utils.js:269

    return unwrapBridgeEnvelope(await page.evaluate(`
      (objName, property) => {
        const api = ggbApplet;
        switch (property) {
          case 'type': return api.getObjectType(objName);
          case 'value': return api.getValueString(objName);
          case 'color': return api.getColor(objName);
          case 'visible': return api.getVisible(objName);
          case 'caption': return api.getCaption(objName) || '';
          case 'xcoord': return api.getXcoord(objName);
          case 'ycoord': return api.getYcoord(objName);
          case 'definition': return api.getDefinitionString(objName);
          case 'command': return api.getCommandString(objName);
          default: return null;
        }
      }
    `, objName, property));
  } catch (err) {
    throw new CommandExecutionError(`Failed to read GeoGebra object property: ${err?.message || err}`);
  }
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify the object name exists first with a list-objects/objType command; GeoGebra labels are case-sensitive.
  2. Wait for the applet to finish loading (or retry after a short delay) before reading properties.
  3. Check that the requested property is valid for that object type (e.g. xcoord/ycoord only for points/curves).
  4. Inspect the nested err.message in the message to distinguish a missing-object throw from a page/bridge failure.
  5. If the page navigated or crashed, re-open the GeoGebra page and re-create/reload the applet before retrying.

Example fix

// before — reading a coordinate possibly before object exists
const x = await ggbGetProperty(page, 'A', 'xcoord');
// after — guard: wait for the object, then read
await waitForObjectCount(page, 1); // or check objType first
if ((await ggbGetProperty(page, 'A', 'type')) === 'point') {
  const x = await ggbGetProperty(page, 'A', 'xcoord');
}
Defensive patterns

Strategy: try-catch

Validate before calling

const type = await ggbGetProperty(page, objName, 'type').catch(() => null);
if (type == null) throw new Error(`GeoGebra object '${objName}' not available yet`);

Type guard

function isReadResult(v) { return v !== undefined && v !== null; }

Try / catch

try {
  const value = await ggbGetProperty(page, objName, property);
} catch (err) {
  if (/Failed to read GeoGebra object property/.test(err.message)) {
    // retry after checking the object exists / applet is loaded
  } else throw err;
}

Prevention

When it happens

Trigger: Calling ggbGetProperty (directly or via the result/val/objType/x/y commands) when: the object name does not exist in the applet so ggbApplet.getXcoord/etc throws; ggbApplet is undefined because the GeoGebra applet has not finished loading; the property name is unknown (switch default returns null, and unwrapBridgeEnvelope may fail); or the page/context crashed or navigated away during page.evaluate.

Common situations: Running a GeoGebra CLI command before the applet finished async initialization; a typo in the object label (GeoGebra labels are case-sensitive, e.g. 'a' vs 'A'); querying a property unsupported for the object type (e.g. xcoord of a text object or a list); the browser tab reloading or the evaluation script failing inside page.evaluate.

Related errors


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