{"record":{"id":"628f1948a725b3dd","repo":"Hmbown/CodeWhale","slug":"invalid-container","errorCode":"invalid_container","errorMessage":"docker computers need a valid container name","messagePattern":"docker computers need a valid container name","errorType":"error_code","errorClass":"RegistryError","httpStatus":null,"severity":"error","filePath":"crates/tui/plugins/computer-use/src/registry.mjs","lineNumber":105,"sourceCode":"    if (!rest.host || !/^[A-Za-z0-9._-]+$/.test(rest.host)) {\n      throw new RegistryError(\"invalid_host\", \"ssh computers need a valid host (letters, digits, dot, dash, underscore)\");\n    }\n    if (rest.port != null && (!Number.isInteger(rest.port) || rest.port < 1 || rest.port > 65535)) {\n      throw new RegistryError(\"invalid_port\", \"port must be an integer in 1..65535\");\n    }\n    if (rest.user != null && !/^[a-zA-Z0-9._-]+$/.test(rest.user)) {\n      throw new RegistryError(\"invalid_user\", \"user must be a plain name\");\n    }\n  }\n  if (transport === \"hdc\") {\n    if (rest.target != null && !/^[A-Za-z0-9._-]*$/.test(rest.target)) {\n      throw new RegistryError(\"invalid_target\", \"hdc target key contains invalid characters\");\n    }\n    rest.platform = \"harmonyos\";\n  }\n  if (transport === \"docker\") {\n    if (!rest.container || !/^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/.test(rest.container)) {\n      throw new RegistryError(\"invalid_container\", \"docker computers need a valid container name\");\n    }\n    // Spawned containers always run the Linux desktop image.\n    rest.platform = rest.platform ?? \"linux\";\n  }\n  const reg = load();\n  const prev = reg.computers[id];\n  reg.computers[id] = {\n    ...prev,\n    id,\n    transport,\n    label: label ?? prev?.label ?? id,\n    registeredAt: prev?.registeredAt ?? new Date().toISOString(),\n    ...rest,\n  };\n  save(reg);\n  return reg.computers[id];\n}\n","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/plugins/computer-use/src/registry.mjs#L87-L123","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass the exact container name (or ID) as shown by `docker ps --format '{{.Names}}'` with any leading slash stripped.","Rename the container to a Docker-valid name (docker rename) if it does not conform, then register that name.","Ensure the value is a container name, not an image reference or compose service key.","Validate against ^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$ before calling register()."],"exampleFix":"// before\nregister({ id: \"d\", transport: \"docker\", container: \"/ubuntu-desktop\" });\n// after\nregister({ id: \"d\", transport: \"docker\", container: \"ubuntu-desktop\" });","handlingStrategy":"validation","validationCode":"const CONTAINER_RE = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/;\nif (typeof container !== \"string\" || !CONTAINER_RE.test(container)) throw new Error(\"container must be a valid Docker container name\");","typeGuard":"const isDockerContainer = (c) => typeof c === \"string\" && /^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/.test(c);","tryCatchPattern":"try {\n  register(cfg);\n} catch (e) {\n  if (e?.code === \"invalid_container\") throw new Error(`\"${cfg.container}\" is not a container name; use docker ps --format '{{.Names}}'`);\n  throw e;\n}","preventionTips":["Strip the leading slash when parsing docker ps output","Pass container names, not image references or compose service keys","Docker forbids leading - or . in names — account for that","Verify with docker ps that the container exists under that exact name"],"tags":["validation","docker","registry","javascript"],"backgroundTag":"invalid-argument-value","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T11:17:16.035Z"}