can1357/oh-my-pi · error

Host address cannot be empty

Error message

Host address cannot be empty

What it means

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.

Source

Thrown at packages/coding-agent/src/ssh/config-writer.ts:94

	}
	return undefined;
}

/**
 * Add an SSH host to a config file.
 *
 * @throws Error if host name already exists or validation fails
 */
export async function addSSHHost(filePath: string, name: string, hostConfig: SSHHostConfig): Promise<void> {
	// Validate host name
	const nameError = validateHostName(name);
	if (nameError) {
		throw new Error(nameError);
	}

	// Validate host field
	if (!hostConfig.host) {
		throw new Error("Host address cannot be empty");
	}

	// Read existing config
	const existing = await readSSHConfigFile(filePath);

	// Check for duplicate name
	if (existing.hosts?.[name]) {
		throw new Error(`Host "${name}" already exists in ${filePath}`);
	}

	// Add host
	const updated: SSHConfigFile = {
		...existing,
		hosts: {
			...existing.hosts,
			[name]: hostConfig,
		},
	};

View on GitHub (pinned to 9690622007)

Solutions

  1. Provide a non-empty host address in the SSHHostConfig
  2. In CLI handlers (handleAdd/#handleAdd), validate the address argument before constructing the config object
  3. Default the host to the host name when they are intentionally identical

Example fix

// before
await addSSHHost(path, name, { host: "", user: "root" });
// after
await addSSHHost(path, name, { host: "ssh.example.com", user: "root" });
Defensive patterns

Strategy: validation

Validate before calling

if (!hostConfig.host) throw new Error("host address required");
await addSSHHost(filePath, name, hostConfig);

Type guard

function hasHost(c): c is SSHHostConfig & { host: string } { return typeof c.host === "string" && c.host.length > 0; }

Try / catch

null

Prevention

When it happens

Trigger: Calling addSSHHost with hostConfig = { host: "", ... } or { host: undefined } — any falsy host value.

Common situations: 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.

Understand the failure class

Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/d9f7d3a3673dfe25. Report an issue: GitHub.