Hmbown/CodeWhale · error · RegistryError
invalid_id
invalid_id
Error message
computer id must match " + ID_RE
What it means
RegistryError "invalid_id": register() rejects any computer id that is missing or does not match ID_RE. The registry uses ids as object keys in the saved computers map and exposes them to tool calls, so only a constrained character set is accepted. This validation runs before any transport-specific checks, so it fires first when both id and transport are bad.
Solutions
- Choose an id that matches ID_RE — use letters, digits, and simple separators like dashes (e.g. "desk-pc", "lab-ssh01").
- Check the exact pattern by inspecting ID_RE at the top of registry.mjs and conform to it.
- Sanitize or slugify any externally supplied id before passing it to register().
- Ensure id is a non-empty string (not undefined/null/number) in the object passed to register().
Example fix
// before
register({ id: inputHostname, transport: "ssh", host: inputHostname });
// after
const id = inputHostname.replace(/[^A-Za-z0-9._-]/g, "-");
register({ id, transport: "ssh", host: inputHostname }); Defensive patterns
Strategy: validation
Validate before calling
// const ID_RE = <pattern from registry.mjs>;
function validId(id) { return typeof id === "string" && id.length > 0 && ID_RE.test(id); }
if (!validId(id)) throw new Error(`id "${id}" must match ${ID_RE}`); Type guard
const isRegistryId = (v) => typeof v === "string" && v.length > 0 && /^[A-Za-z0-9._-]+$/.test(v);
Try / catch
try {
register({ id, transport, ...rest });
} catch (e) {
if (e instanceof RegistryError && e.code === "invalid_id") {
throw new Error(`Bad computer id "${id}": use letters/digits/dots/dashes`);
}
throw e;
} Prevention
- Slugify externally supplied ids before registering
- Keep ids to [A-Za-z0-9._-] by convention
- Never derive ids from free-form user input without sanitizing
- Check ID_RE in registry.mjs when in doubt
When it happens
Trigger: Calling register({ id: undefined, ... }), register({ id: "", ... }), or register({ id: "my computer!", ... }) with characters outside ID_RE (e.g. spaces, slashes, uppercase-sensitive patterns, colons).
Common situations: Copy-pasting a hostname or device serial containing colons/spaces into the id field; building an id from user input without sanitizing; forgetting to pass id entirely when spreading config into register().
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- invalid_container
- invalid_host
- invalid_transport
- reserved_id
- Choose an appearance file smaller than 4 KiB.
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/de70ddd42000cf61.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/plugins/computer-use/src/registry.mjs:79
const c = reg.computers[id];
if (!c) throw new RegistryError("unknown_computer", `no computer registered with id "${id}". Use computer_list.`);
return c;
}
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") {View on GitHub (pinned to 73e0f67d83)