Hmbown/CodeWhale · error · RuntimeError

invalid_value

Error message

invalid_value

What it means

When the target has no EditableText interface, set_value falls back to the AT-SPI Value interface: it parses the requested value as a float and rejects non-finite values with RuntimeError("invalid_value") before assigning numeric.currentValue. This keeps NaN/Infinity from being pushed into a numeric control.

Solutions

  1. Pass a finite numeric string or number, e.g. "42" or "3.14"
  2. Pre-parse and validate with Number.isFinite in the caller before set_value
  3. Use the appropriate numeric control's range (check min/max) to avoid a subsequent rejection

Example fix

// before
await backend.set_value({ target: "#volume", value: "NaN" }) // invalid_value
// after
await backend.set_value({ target: "#volume", value: "75" });
Defensive patterns

Strategy: validation

Validate before calling

const n = Number(value);
if (!Number.isFinite(n)) throw new Error(`set_value on a numeric control requires a finite number, got ${value}`);

Type guard

const isFiniteNumeric = (v) => { const n = Number(v); return v !== "" && v != null && Number.isFinite(n); };

Try / catch

try { return await backend.set_value({ target, value }); } catch (e) { if (String(e).includes("invalid_value")) { throw new Error(`not a finite numeric value: ${JSON.stringify(value)}`); } throw e; }

Prevention

When it happens

Trigger: Calling set_value on a numeric control (slider, spinbox, progress) with value="NaN", value="Infinity", value="-Infinity", or any string that float() cannot parse — float() raises ValueError first for non-numeric strings.

Common situations: Automating sliders/spinboxes with symbolic values instead of numbers; passing a locale-formatted number ("1,234.5") that float() rejects; generated code substituting 'NaN' for missing data.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/69e82f0919ba7db0. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/plugins/computer-use/src/backends/linux.mjs:714

        raise RuntimeError("element_disabled")
    try:
        editor = found.queryEditableText()
    except NotImplementedError:
        editor = None
    if editor is not None:
        if not state.contains(pyatspi.STATE_EDITABLE):
            raise RuntimeError("element_read_only")
        if not editor.setTextContents(extra):
            raise RuntimeError("value_rejected")
        text = found.queryText()
        after = text.getText(0, text.characterCount)
        if after != extra:
            raise RuntimeError("value_verification_failed")
    else:
        import math
        desired = float(extra)
        if not math.isfinite(desired):
            raise RuntimeError("invalid_value")
        numeric = found.queryValue()
        numeric.currentValue = desired
        after = numeric.currentValue
        if after != desired:
            raise RuntimeError("value_verification_failed")
    print(json.dumps({"ok": True, "after": after}))`, String(value));
      if (!out.ok) throw new ExecError(`set_value failed: ${out.code}`);
      return { action_sent: true, strategy: "a11y", verified: true, after: out.after };
    },
    select_text: async () => { throw new ExecError("select_text is not implemented on the linux backend — fail-closed"); },
    perform_action: async ({ target, action }) => {
      const body = `    a = found.queryAction()
    names = [a.getName(i) for i in range(a.nActions)]
    want = (extra or "click").lower()
    match = next((n for n in names if n.lower() == want), None)
    if match is None and want == "click":
        match = next((n for n in names if n.lower() in ("click", "press", "activate")), None)
    if match is None:

View on GitHub (pinned to 73e0f67d83)