{"record":{"id":"bad9a6c736168bc1","repo":"can1357/oh-my-pi","slug":"host-name-not-found-in-filepath","errorCode":null,"errorMessage":"Host \"${name}\" not found in ${filePath}","messagePattern":"Host \"(.+?)\" not found in (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/ssh/config-writer.ts","lineNumber":163,"sourceCode":"\t\t},\n\t};\n\n\t// Write back\n\tawait writeSSHConfigFile(filePath, updated);\n}\n\n/**\n * Remove an SSH host from a config file.\n *\n * @throws Error if host doesn't exist\n */\nexport async function removeSSHHost(filePath: string, name: string): Promise<void> {\n\t// Read existing config\n\tconst existing = await readSSHConfigFile(filePath);\n\n\t// Check if host exists\n\tif (!existing.hosts?.[name]) {\n\t\tthrow new Error(`Host \"${name}\" not found in ${filePath}`);\n\t}\n\n\t// Remove host\n\tconst { [name]: _removed, ...remaining } = existing.hosts;\n\tconst updated: SSHConfigFile = {\n\t\t...existing,\n\t\thosts: remaining,\n\t};\n\n\t// Write back\n\tawait writeSSHConfigFile(filePath, updated);\n}\n\n/**\n * List all host names in a config file.\n */\nexport async function listSSHHosts(filePath: string): Promise<string[]> {\n\tconst config = await readSSHConfigFile(filePath);","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/ssh/config-writer.ts#L145-L181","documentation":"removeSSHHost looks up the host name in the parsed config and throws if no entry with that exact name exists at filePath. Removal is by literal alias match; pattern-style or case-differing names will not be found.","triggerScenarios":"Calling removeSSHHost(filePath, name) where existing.hosts[name] is undefined — name never added, already removed, or spelled differently.","commonSituations":"Idempotent cleanup scripts running twice, typos in the alias, names differing in case, or editing a different config file (project vs ~/.ssh/config) than the one containing the host.","solutions":["List hosts via readSSHConfigFile(filePath) to confirm the exact stored name","Verify you are targeting the correct config file path","Make the removal idempotent by checking existence before calling","Use updateSSHHost instead if the goal was to modify, not delete"],"exampleFix":"// before\nawait removeSSHHost(path, \"Prod\"); // stored as \"prod\"\n// after\nconst cfg = await readSSHConfigFile(path);\nif (cfg.hosts?.[\"Prod\"]) await removeSSHHost(path, \"Prod\");","handlingStrategy":"validation","validationCode":"const hosts = (await readSSHConfigFile(filePath)).hosts ?? {};\nif (hosts[name]) await removeSSHHost(filePath, name);","typeGuard":"null","tryCatchPattern":"try { await removeSSHHost(p, name); } catch (e) { if (!(e instanceof Error && e.message.includes(\"not found\"))) throw e; /* already gone: idempotent */ }","preventionTips":["Read the config to confirm exact stored aliases (case-sensitive)","Verify which config file (project vs user) you are editing","Design removal flows to tolerate already-missing entries"],"tags":["ssh","not-found","config-conflict"],"backgroundTag":"entry-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}