{"record":{"id":"d9f7d3a3673dfe25","repo":"can1357/oh-my-pi","slug":"host-address-cannot-be-empty","errorCode":null,"errorMessage":"Host address cannot be empty","messagePattern":"Host address cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/ssh/config-writer.ts","lineNumber":94,"sourceCode":"\t}\n\treturn undefined;\n}\n\n/**\n * Add an SSH host to a config file.\n *\n * @throws Error if host name already exists or validation fails\n */\nexport async function addSSHHost(filePath: string, name: string, hostConfig: SSHHostConfig): Promise<void> {\n\t// Validate host name\n\tconst nameError = validateHostName(name);\n\tif (nameError) {\n\t\tthrow new Error(nameError);\n\t}\n\n\t// Validate host field\n\tif (!hostConfig.host) {\n\t\tthrow new Error(\"Host address cannot be empty\");\n\t}\n\n\t// Read existing config\n\tconst existing = await readSSHConfigFile(filePath);\n\n\t// Check for duplicate name\n\tif (existing.hosts?.[name]) {\n\t\tthrow new Error(`Host \"${name}\" already exists in ${filePath}`);\n\t}\n\n\t// Add host\n\tconst updated: SSHConfigFile = {\n\t\t...existing,\n\t\thosts: {\n\t\t\t...existing.hosts,\n\t\t\t[name]: hostConfig,\n\t\t},\n\t};","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/ssh/config-writer.ts#L76-L112","documentation":"addSSHHost rejects an SSHHostConfig whose `host` field is empty, since an entry with no target address is useless. The check runs after name validation and before reading the config file.","triggerScenarios":"Calling addSSHHost with hostConfig = { host: \"\", ... } or { host: undefined } — any falsy host value.","commonSituations":"CLI add flow invoked with a missing --hostname/address argument, form submissions where the address field was skipped, or objects built by code paths that only set optional fields.","solutions":["Provide a non-empty host address in the SSHHostConfig","In CLI handlers (handleAdd/#handleAdd), validate the address argument before constructing the config object","Default the host to the host name when they are intentionally identical"],"exampleFix":"// before\nawait addSSHHost(path, name, { host: \"\", user: \"root\" });\n// after\nawait addSSHHost(path, name, { host: \"ssh.example.com\", user: \"root\" });","handlingStrategy":"validation","validationCode":"if (!hostConfig.host) throw new Error(\"host address required\");\nawait addSSHHost(filePath, name, hostConfig);","typeGuard":"function hasHost(c): c is SSHHostConfig & { host: string } { return typeof c.host === \"string\" && c.host.length > 0; }","tryCatchPattern":"null","preventionTips":["Always set host in SSHHostConfig objects","Validate form/CLI address fields before constructing configs","Fall back to the host name when no separate address is given"],"tags":["ssh","validation","missing-field"],"backgroundTag":"missing-required-field","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}