{"record":{"id":"071a6e95d4b33190","repo":"Hmbown/CodeWhale","slug":"invalid-target","errorCode":"invalid_target","errorMessage":"hdc target key contains invalid characters","messagePattern":"hdc target key contains invalid characters","errorType":"validation","errorClass":"RegistryError","httpStatus":null,"severity":"error","filePath":"crates/tui/plugins/computer-use/src/registry.mjs","lineNumber":99,"sourceCode":"    throw new RegistryError(\"invalid_transport\", \"transport must be one of: local, ssh, hdc, docker\");\n  }\n  if (id === \"local\" && transport !== \"local\") {\n    throw new RegistryError(\"reserved_id\", '\"local\" is reserved for this machine');\n  }\n  if (transport === \"ssh\") {\n    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(),","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/plugins/computer-use/src/registry.mjs#L81-L117","documentation":"RegistryError \"invalid_target\": for hdc transports, an optional rest.target must match ^[A-Za-z0-9._-]*$ (note: empty is allowed because the regex uses *). The target is the hdc device key passed on the hdc command line, so colons (as in connect-style addresses) and other punctuation are rejected. A valid registration also sets platform to \"harmonyos\".","triggerScenarios":"register({ id: \"phone\", transport: \"hdc\", target: \"192.168.1.10:5555\" }) (colon in wireless hdc address); target containing spaces or \"+\"; target from a mixed device list that includes adb serials with other separators.","commonSituations":"Using the host:port form shown by `hdc tconn` output directly as target; switching an existing adb-based config (serials may contain other characters) over to hdc.","solutions":["Use the plain serial/key as printed by `hdc list targets` without host:port — connect first via hdc tconn, then reference the connected key that conforms.","Omit target to let hdc pick the single connected device.","Sanitize the target: replace disallowed characters or connect by TCP and use the resulting registry key.","If you need a colon-bearing address, set up a name/alias at the hdc layer rather than embedding it here."],"exampleFix":"// before\nregister({ id: \"phone\", transport: \"hdc\", target: \"192.168.1.10:5555\" });\n// after\n// run `hdc tconn 192.168.1.10:5555` once, then use the listed key\nregister({ id: \"phone\", transport: \"hdc\", target: \"192.168.1.10+5555\" });","handlingStrategy":"validation","validationCode":"const TARGET_RE = /^[A-Za-z0-9._-]*$/;\nif (target != null && (typeof target !== \"string\" || !TARGET_RE.test(target))) throw new Error(\"hdc target contains invalid characters (no colons)\");","typeGuard":"const isHdcTarget = (t) => typeof t === \"string\" && /^[A-Za-z0-9._-]*$/.test(t);","tryCatchPattern":"try {\n  register(cfg);\n} catch (e) {\n  if (e?.code === \"invalid_target\") throw new Error(`Target \"${cfg.target}\" rejected; connect via hdc tconn and use the key from hdc list targets`);\n  throw e;\n}","preventionTips":["Use keys from `hdc list targets`, not raw host:port addresses","Run `hdc tconn host:port` once, then register the resulting key","Omit target when only one device is connected","Remember the colon in wireless addresses is the usual offender"],"tags":["validation","hdc","harmonyos","registry"],"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-22T21:17:16.096Z"}