can1357/oh-my-pi · error
Host "${name}" not found in ${filePath}
Error message
Host "${name}" not found in ${filePath} What it means
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.
Source
Thrown at packages/coding-agent/src/ssh/config-writer.ts:163
},
};
// Write back
await writeSSHConfigFile(filePath, updated);
}
/**
* Remove an SSH host from a config file.
*
* @throws Error if host doesn't exist
*/
export async function removeSSHHost(filePath: string, name: string): Promise<void> {
// Read existing config
const existing = await readSSHConfigFile(filePath);
// Check if host exists
if (!existing.hosts?.[name]) {
throw new Error(`Host "${name}" not found in ${filePath}`);
}
// Remove host
const { [name]: _removed, ...remaining } = existing.hosts;
const updated: SSHConfigFile = {
...existing,
hosts: remaining,
};
// Write back
await writeSSHConfigFile(filePath, updated);
}
/**
* List all host names in a config file.
*/
export async function listSSHHosts(filePath: string): Promise<string[]> {
const config = await readSSHConfigFile(filePath);View on GitHub (pinned to 9690622007)
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
Example fix
// before await removeSSHHost(path, "Prod"); // stored as "prod" // after const cfg = await readSSHConfigFile(path); if (cfg.hosts?.["Prod"]) await removeSSHHost(path, "Prod");
Defensive patterns
Strategy: validation
Validate before calling
const hosts = (await readSSHConfigFile(filePath)).hosts ?? {};
if (hosts[name]) await removeSSHHost(filePath, name); Type guard
null
Try / catch
try { await removeSSHHost(p, name); } catch (e) { if (!(e instanceof Error && e.message.includes("not found"))) throw e; /* already gone: idempotent */ } Prevention
- 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
When it happens
Trigger: Calling removeSSHHost(filePath, name) where existing.hosts[name] is undefined — name never added, already removed, or spelled differently.
Common situations: 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.
Related errors
- Host "${name}" already exists in ${filePath}
- imageUrls exposure "ssh" requires imageUrls.publicBaseUrl
- imageUrls exposure "ssh" requires imageUrls.sshTarget
- ssh reverse forward to ${config.sshTarget} exited with code
- SFTP password injection is unsupported by the shared SSH tra
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/bad9a6c736168bc1.
Report an issue: GitHub.