{"record":{"id":"5b1394c3330e312d","repo":"jackwener/OpenCLI","slug":"data-err","errorCode":null,"errorMessage":"data.err","messagePattern":"data\\.err","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/antigravity/audit-extras.js","lineNumber":165,"sourceCode":"    ],\n    columns: ['Field', 'Value'],\n    func: async (page, kwargs) => {\n        const idx = Number.isInteger(kwargs?.index) ? kwargs.index : null;\n        const data = unwrapEvaluateResult(await page.evaluate(`(() => {\n      const isVis = (el) => { const r = el.getBoundingClientRect(); return r.width > 1 && r.height > 1; };\n      const btns = Array.from(document.querySelectorAll('button[aria-label=\"Copy code\"]')).filter(isVis);\n      if (!btns.length) return null;\n      const idx = ${idx === null ? 'btns.length - 1' : (idx - 1)};\n      const btn = btns[idx];\n      if (!btn) return { err: 'index ' + (${idx} ?? 'last') + ' out of range. Have ' + btns.length + ' code blocks.' };\n      // Find the <code> or <pre> element inside the parent block.\n      let container = btn;\n      for (let i = 0; i < 6 && container.parentElement; i++) container = container.parentElement;\n      const code = container.querySelector('pre, code');\n      return { text: code ? (code.innerText || '').trim() : (container.innerText || '').trim(), total: btns.length };\n    })()`));\n        if (!data) throw new EmptyResultError('antigravity copy-code', 'No code blocks visible.');\n        if (data.err) throw new CommandExecutionError(data.err, '');\n        return [\n            { Field: 'TotalCodeBlocks', Value: String(data.total) },\n            { Field: 'PickedIndex', Value: String(idx === null ? data.total : idx) },\n            { Field: 'Length', Value: String((data.text || '').length) + ' chars' },\n            { Field: 'Code', Value: data.text || '' },\n        ];\n    },\n});\n\n// -------- settings --------\ncli({\n    site: 'antigravity',\n    name: 'settings',\n    access: 'write',\n    description: 'Click the Antigravity settings button (matched by data-testid=\"settings-button\").',\n    domain: '127.0.0.1',\n    strategy: Strategy.UI,\n    browser: true,","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/antigravity/audit-extras.js#L147-L183","documentation":"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.","triggerScenarios":"`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).","commonSituations":"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.","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."],"exampleFix":"// before\nconst code = container.querySelector('pre, code');\n\n// after\nconst code = container.querySelector('pre, code')\n  || container.querySelector('[class*=\"code\"]');  // tolerate nesting changes","handlingStrategy":"try-catch","validationCode":"const probe = await page.evaluate(\"(() => { try { return { ok: !!document.querySelector('pre, code') }; } catch (e) { return { ok: false, err: String(e) }; } })()\");\nif (!probe.ok) throw new Error('Page structure incompatible: ' + probe.err);","typeGuard":"function isCleanScrape(data) {\n  return data != null && typeof data === 'object' && !('err' in data && data.err);\n}","tryCatchPattern":"try {\n  await runCmd('antigravity copy-code 0');\n} catch (e) {\n  if (e.code === 'EXEC') {\n    console.error('In-page scrape failed:', e.message); // message carries data.err\n    // adjust selectors / pierce shadow DOM, then retry\n  } else throw e;\n}","preventionTips":["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."],"tags":["in-page-eval-error","dom-structure","browser-automation"],"backgroundTag":"in-page-evaluation-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}