Hmbown/CodeWhale · error · RegistryError

invalid_container

invalid_container

Error message

docker computers need a valid container name

What it means

RegistryError "invalid_container": for docker transports, rest.container is required and must match ^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$ — Docker's own container-name rules (must start with an alphanumeric, 1-128 chars of [A-Za-z0-9_.-]). Valid registrations default platform to "linux" since the desktop image runs Linux.

Solutions

  1. Pass the exact container name (or ID) as shown by `docker ps --format '{{.Names}}'` with any leading slash stripped.
  2. Rename the container to a Docker-valid name (docker rename) if it does not conform, then register that name.
  3. Ensure the value is a container name, not an image reference or compose service key.
  4. Validate against ^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$ before calling register().

Example fix

// before
register({ id: "d", transport: "docker", container: "/ubuntu-desktop" });
// after
register({ id: "d", transport: "docker", container: "ubuntu-desktop" });
Defensive patterns

Strategy: validation

Validate before calling

const CONTAINER_RE = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/;
if (typeof container !== "string" || !CONTAINER_RE.test(container)) throw new Error("container must be a valid Docker container name");

Type guard

const isDockerContainer = (c) => typeof c === "string" && /^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/.test(c);

Try / catch

try {
  register(cfg);
} catch (e) {
  if (e?.code === "invalid_container") throw new Error(`"${cfg.container}" is not a container name; use docker ps --format '{{.Names}}'`);
  throw e;
}

Prevention

When it happens

Trigger: register({ id: "d", transport: "docker" }) with no container; container: "/my-container" (leading slash from docker ps parsing); container starting with "-" or "."; container longer than 128 chars; container with "@" from a compose service ref.

Common situations: Passing a docker-compose service name that differs from the actual container name; scraping `docker ps` output and including the leading slash; using image names (which contain "/" and ":") instead of container names.

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/628f1948a725b3dd. Report an issue: GitHub.

Appendix: source

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

    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";
  }
  if (transport === "docker") {
    if (!rest.container || !/^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/.test(rest.container)) {
      throw new RegistryError("invalid_container", "docker computers need a valid container name");
    }
    // Spawned containers always run the Linux desktop image.
    rest.platform = rest.platform ?? "linux";
  }
  const reg = load();
  const prev = reg.computers[id];
  reg.computers[id] = {
    ...prev,
    id,
    transport,
    label: label ?? prev?.label ?? id,
    registeredAt: prev?.registeredAt ?? new Date().toISOString(),
    ...rest,
  };
  save(reg);
  return reg.computers[id];
}

View on GitHub (pinned to 73e0f67d83)