Hmbown/CodeWhale · error · RegistryError

reserved_id

reserved_id

Error message

"local" is reserved for this machine

What it means

RegistryError "reserved_id": the id "local" always refers to the machine the plugin runs on, so register() rejects registering "local" with a transport other than "local", and remove() refuses to delete it. This keeps the implicit local computer usable as the default active target. It is a semantic rule on top of the ID_RE format check.

Solutions

  1. For a remote machine, pick a different id (e.g. "remote-local", the actual hostname slug).
  2. If you truly mean this machine, omit the entry entirely — "local" is registered implicitly with transport "local".
  3. Skip id "local" in bulk remove/registration loops; treat it as a reserved constant.
  4. To reset the active computer, set active to another registered id rather than removing "local".

Example fix

// before
remove("local"); // reset registry
// after
for (const id of Object.keys(load().computers)) {
  if (id !== "local") remove(id);
}
Defensive patterns

Strategy: validation

Validate before calling

if (id === "local" && transport !== "local") throw new Error('"local" is reserved; pick another id');
if (action === "remove" && id === "local") throw new Error('"local" cannot be removed');

Type guard

const isReservedId = (id) => id === "local";

Try / catch

try {
  remove(id);
} catch (e) {
  if (e?.code === "reserved_id") console.warn('"local" is a builtin and stays registered');
  else throw e;
}

Prevention

When it happens

Trigger: register({ id: "local", transport: "ssh", host: "..." }) — shadowing the built-in local entry with a remote transport; remove("local") — attempting to delete the built-in entry.

Common situations: Script that registers every machine in an inventory list which happens to include the controller itself named "local"; cleanup script trying to reset the registry by deleting all entries including "local".

Related errors


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

Appendix: source

Thrown at crates/tui/plugins/computer-use/src/registry.mjs:84

export function active() { return get(list().active); }

/** Switch the active computer. Returns the computer entry. */
export function switchTo(id) {
  const c = get(id); // throws unknown_computer
  const reg = load();
  reg.active = c.id;
  save(reg);
  return c;
}

/** Register or update a computer. Returns the entry. */
export function register({ id, transport, label, ...rest }) {
  if (!id || !ID_RE.test(id)) throw new RegistryError("invalid_id", "computer id must match " + ID_RE);
  if (!["local", "ssh", "hdc", "docker"].includes(transport)) {
    throw new RegistryError("invalid_transport", "transport must be one of: local, ssh, hdc, docker");
  }
  if (id === "local" && transport !== "local") {
    throw new RegistryError("reserved_id", '"local" is reserved for this machine');
  }
  if (transport === "ssh") {
    if (!rest.host || !/^[A-Za-z0-9._-]+$/.test(rest.host)) {
      throw new RegistryError("invalid_host", "ssh computers need a valid host (letters, digits, dot, dash, underscore)");
    }
    if (rest.port != null && (!Number.isInteger(rest.port) || rest.port < 1 || rest.port > 65535)) {
      throw new RegistryError("invalid_port", "port must be an integer in 1..65535");
    }
    if (rest.user != null && !/^[a-zA-Z0-9._-]+$/.test(rest.user)) {
      throw new RegistryError("invalid_user", "user must be a plain name");
    }
  }
  if (transport === "hdc") {
    if (rest.target != null && !/^[A-Za-z0-9._-]*$/.test(rest.target)) {
      throw new RegistryError("invalid_target", "hdc target key contains invalid characters");
    }
    rest.platform = "harmonyos";
  }

View on GitHub (pinned to 73e0f67d83)