{"record":{"id":"faccaa116a8e1b22","repo":"Hmbown/CodeWhale","slug":"set-value-failed-out-code","errorCode":null,"errorMessage":"set_value failed: ${out.code}","messagePattern":"set_value failed: (.+?)","errorType":"exception","errorClass":"ExecError","httpStatus":null,"severity":"error","filePath":"crates/tui/plugins/computer-use/src/backends/linux.mjs","lineNumber":721,"sourceCode":"            raise RuntimeError(\"element_read_only\")\n        if not editor.setTextContents(extra):\n            raise RuntimeError(\"value_rejected\")\n        text = found.queryText()\n        after = text.getText(0, text.characterCount)\n        if after != extra:\n            raise RuntimeError(\"value_verification_failed\")\n    else:\n        import math\n        desired = float(extra)\n        if not math.isfinite(desired):\n            raise RuntimeError(\"invalid_value\")\n        numeric = found.queryValue()\n        numeric.currentValue = desired\n        after = numeric.currentValue\n        if after != desired:\n            raise RuntimeError(\"value_verification_failed\")\n    print(json.dumps({\"ok\": True, \"after\": after}))`, String(value));\n      if (!out.ok) throw new ExecError(`set_value failed: ${out.code}`);\n      return { action_sent: true, strategy: \"a11y\", verified: true, after: out.after };\n    },\n    select_text: async () => { throw new ExecError(\"select_text is not implemented on the linux backend — fail-closed\"); },\n    perform_action: async ({ target, action }) => {\n      const body = `    a = found.queryAction()\n    names = [a.getName(i) for i in range(a.nActions)]\n    want = (extra or \"click\").lower()\n    match = next((n for n in names if n.lower() == want), None)\n    if match is None and want == \"click\":\n        match = next((n for n in names if n.lower() in (\"click\", \"press\", \"activate\")), None)\n    if match is None:\n        print(json.dumps({\"ok\": False, \"code\": \"action_not_found: \" + \",\".join(names)}))\n    else:\n        a.doAction(names.index(match))\n        print(json.dumps({\"ok\": True, \"sent\": True}))`;\n      const out = await atspiResolve(target, body, String(action));\n      if (!out.ok) throw new ExecError(`perform_action failed: ${out.code}`);\n      return { action_sent: true, strategy: \"a11y\", action };","sourceCodeStart":703,"sourceCodeEnd":739,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/plugins/computer-use/src/backends/linux.mjs#L703-L739","documentation":"set_value sets a numeric value on an AT-SPI value element via an embedded python script that writes and re-reads the value for verification. The library throws this when the script reported ok=false with a code — e.g. the element does not expose a value interface, or the write did not stick (value_verification_failed).","triggerScenarios":"Target element has no queryValue interface (not a slider/spinbox/progress); the value is read-only or clamped by the app so the post-write readback differs (RuntimeError value_verification_failed); stale element path resolved to the wrong node; a11y exceptions inside the script bubbling to ok=false.","commonSituations":"Trying to set_value on plain text fields (use type/key instead); sliders whose min/max reject the requested value; Electron apps exposing value poorly; paths captured from an outdated get_app_state snapshot.","solutions":["Check out.code in practice: target value_interface vs value_verification_failed and treat accordingly.","Only call set_value on elements that truly expose the AT-SPI Value interface (sliders, spinners); type into text fields instead.","Clamp the requested value to the element's minValue/maxValue before writing.","Refresh the element path via get_app_state and retry once — stale nodes commonly cause the failure."],"exampleFix":"// before\nawait backend.set_value({ target, value: 500 }); // slider max is 100 -> verification failed\n// after\nconst clamped = Math.min(100, Math.max(0, 500));\nawait backend.set_value({ target, value: clamped });","handlingStrategy":"try-catch","validationCode":"const el = await findElement(state, targetPath);\nif (!el.interfaces?.includes('Value')) throw new Error('element has no AT-SPI Value interface');","typeGuard":null,"tryCatchPattern":"try {\n  return await backend.set_value({ target, value });\n} catch (e) {\n  if (String(e.message).includes('set_value failed:')) {\n    const fresh = await backend.get_app_state({ app_ref });\n    return backend.set_value({ target: reResolve(fresh), value: clamp(value) });\n  }\n  throw e;\n}","preventionTips":["Only use set_value on sliders/spinners, not text fields","Clamp values to the element's documented min/max before writing","Refresh element paths immediately before writes to avoid stale nodes"],"tags":["linux","accessibility","atspi","set-value","verification"],"backgroundTag":"operation-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T21:17:16.096Z"}