Hmbown/CodeWhale · error · RegistryError

invalid_transport

invalid_transport

Error message

transport must be one of: local, ssh, hdc, docker

What it means

RegistryError "invalid_transport": register() only accepts the four transport kinds local, ssh, hdc, docker. Anything else — including close variants like "localhost", "SSH", or "adb" — is rejected because there is no connector implementation for it. The transport decides how the computer-use plugin actually reaches the machine, so an unknown value cannot be registered.

Solutions

  1. Use exactly one of: "local", "ssh", "hdc", "docker" (lowercase).
  2. For an Android device check whether this build supports it via hdc only; switch from "adb" to "hdc" or use ssh/docker instead.
  3. Trim/lowercase any externally supplied transport string before calling register().
  4. Update config files or templates that reference a transport name not in this list.

Example fix

// before
register({ id: "phone", transport: "adb" });
// after
register({ id: "phone", transport: "hdc", target: "<serial>" });
Defensive patterns

Strategy: validation

Validate before calling

const TRANSPORTS = ["local", "ssh", "hdc", "docker"];
if (!TRANSPORTS.includes(transport)) throw new Error(`transport must be one of: ${TRANSPORTS.join(", ")}`);

Type guard

const isTransport = (t) => t === "local" || t === "ssh" || t === "hdc" || t === "docker";

Try / catch

try {
  register(cfg);
} catch (e) {
  if (e?.code === "invalid_transport") console.error(`Unsupported transport "${cfg.transport}"; use local|ssh|hdc|docker`);
  throw e;
}

Prevention

When it happens

Trigger: register({ id: "x", transport: "localhost" }); register({ id: "x", transport: "SSH" }) (case-sensitive); register({ id: "x", transport: "adb" }) when the device is actually HarmonyOS and hdc is meant.

Common situations: Typo in a config file; mixing up adb and hdc when configuring an Android/HarmonyOS device; copying an example that uses a different plugin's transport vocabulary; uppercase from a templating layer.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

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

  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") {
    if (rest.target != null && !/^[A-Za-z0-9._-]*$/.test(rest.target)) {
      throw new RegistryError("invalid_target", "hdc target key contains invalid characters");

View on GitHub (pinned to 73e0f67d83)