jackwener/OpenCLI · error · CommandExecutionError
data.err
Error message
data.err
What it means
CommandExecutionError raised when the 'antigravity copy-code' in-page script returns an object carrying `err` — an error produced inside the browser context while locating or reading the code element (e.g. an exception in the eval script or a malformed result). The library surfaces that page-side error verbatim via `throw new CommandExecutionError(data.err, '')` rather than silently returning empty code text.
Source
Thrown at clis/antigravity/audit-extras.js:165
],
columns: ['Field', 'Value'],
func: async (page, kwargs) => {
const idx = Number.isInteger(kwargs?.index) ? kwargs.index : null;
const data = unwrapEvaluateResult(await page.evaluate(`(() => {
const isVis = (el) => { const r = el.getBoundingClientRect(); return r.width > 1 && r.height > 1; };
const btns = Array.from(document.querySelectorAll('button[aria-label="Copy code"]')).filter(isVis);
if (!btns.length) return null;
const idx = ${idx === null ? 'btns.length - 1' : (idx - 1)};
const btn = btns[idx];
if (!btn) return { err: 'index ' + (${idx} ?? 'last') + ' out of range. Have ' + btns.length + ' code blocks.' };
// Find the <code> or <pre> element inside the parent block.
let container = btn;
for (let i = 0; i < 6 && container.parentElement; i++) container = container.parentElement;
const code = container.querySelector('pre, code');
return { text: code ? (code.innerText || '').trim() : (container.innerText || '').trim(), total: btns.length };
})()`));
if (!data) throw new EmptyResultError('antigravity copy-code', 'No code blocks visible.');
if (data.err) throw new CommandExecutionError(data.err, '');
return [
{ Field: 'TotalCodeBlocks', Value: String(data.total) },
{ Field: 'PickedIndex', Value: String(idx === null ? data.total : idx) },
{ Field: 'Length', Value: String((data.text || '').length) + ' chars' },
{ Field: 'Code', Value: data.text || '' },
];
},
});
// -------- settings --------
cli({
site: 'antigravity',
name: 'settings',
access: 'write',
description: 'Click the Antigravity settings button (matched by data-testid="settings-button").',
domain: '127.0.0.1',
strategy: Strategy.UI,
browser: true,View on GitHub (pinned to 49907e53dc)
Solutions
- Re-run once; mid-navigation races can produce transient page-side errors.
- Inspect the `data.err` text in the error message — it names the actual in-page failure.
- Check whether code blocks are inside shadow DOM/iframes and adjust the eval script to pierce them.
- Update the container-walk/querySelector logic in audit-extras.js if the DOM nesting changed.
Example fix
// before
const code = container.querySelector('pre, code');
// after
const code = container.querySelector('pre, code')
|| container.querySelector('[class*="code"]'); // tolerate nesting changes Defensive patterns
Strategy: try-catch
Validate before calling
const probe = await page.evaluate("(() => { try { return { ok: !!document.querySelector('pre, code') }; } catch (e) { return { ok: false, err: String(e) }; } })()");
if (!probe.ok) throw new Error('Page structure incompatible: ' + probe.err); Type guard
function isCleanScrape(data) {
return data != null && typeof data === 'object' && !('err' in data && data.err);
} Try / catch
try {
await runCmd('antigravity copy-code 0');
} catch (e) {
if (e.code === 'EXEC') {
console.error('In-page scrape failed:', e.message); // message carries data.err
// adjust selectors / pierce shadow DOM, then retry
} else throw e;
} Prevention
- Read the surfaced data.err text — it names the actual in-page failure.
- Handle shadow DOM and iframes in any custom eval scripts.
- Re-run once to rule out mid-navigation races.
- Re-validate container-walk assumptions after UI nesting changes.
When it happens
Trigger: `data.err` is truthy after `page.evaluate(...)` — the in-page function threw (e.g. `code` lookup failed unexpectedly, cross-origin frame access, or the evaluated snippet returned { err: ... } from its own try/catch), typically when the DOM shape deviates from what the script assumes (no <pre>/<code> inside the walked-up parents).
Common situations: Antigravity renders code blocks in shadow DOM or an iframe the script cannot traverse; a UI update nests the copy button differently so walking up 6 parents finds no pre/code; the evaluate call hits a page navigation mid-run.
Related errors
- Still on the video publish page after trying to select 图文. D
- Editing form did not appear after image acquisition. The pag
- Could not trigger "${actionLabels[0]}" action${viaClause}${e
- Unexpected 12306 probe: ${JSON.stringify(probe)}
- Waiting for 12306 tk auth cookie
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/5b1394c3330e312d.
Report an issue: GitHub.