paperclipai/paperclip · error · Error
Hostname is required
Error message
Hostname is required
What it means
Thrown by normalizeHostnameInput when the trimmed input is empty. The function is the canonical hostname normalizer used by hostname/allowed-hosts configuration; it trims then rejects zero-length input before attempting URL parsing. parseHostnameCsv calls it per comma-separated part, so a stray comma or blank segment in a CSV also triggers this.
Source
Thrown at cli/src/config/hostnames.ts:4
export function normalizeHostnameInput(raw: string): string {
const input = raw.trim();
if (!input) {
throw new Error("Hostname is required");
}
try {
const url = input.includes("://") ? new URL(input) : new URL(`http://${input}`);
const hostname = url.hostname.trim().toLowerCase();
if (!hostname) throw new Error("Hostname is required");
return hostname;
} catch {
throw new Error(`Invalid hostname: ${raw}`);
}
}
export function parseHostnameCsv(raw: string): string[] {
if (!raw.trim()) return [];
const unique = new Set<string>();
for (const part of raw.split(",")) {
const hostname = normalizeHostnameInput(part);
unique.add(hostname);View on GitHub (pinned to 67001ec6eb)
Solutions
- Provide a non-empty hostname string after trimming.
- If using parseHostnameCsv, sanitize the CSV to remove empty segments first (filter(Boolean)).
- Guard callers to skip hostname normalization when the input is meant to be optional.
Example fix
// before
const h = normalizeHostnameInput(process.env.HOST ?? '');
// after
const raw = (process.env.HOST ?? '').trim();
if (!raw) throw new Error('HOST env var is required');
const h = normalizeHostnameInput(raw); Defensive patterns
Strategy: validation
Validate before calling
function requireHostname(raw: string): string {
const trimmed = raw.trim();
if (!trimmed) {
throw new Error("Hostname is required");
}
return trimmed;
}
// for CSV inputs, drop empty segments before normalizing:
function sanitizeHostnameCsv(raw: string): string[] {
return Array.from(new Set(
raw.split(",").map((p) => p.trim()).filter(Boolean),
));
} Type guard
function isNonEmptyHostname(raw: string): boolean {
return raw.trim().length > 0;
} Prevention
- Trim and reject empty strings at the form/env-var boundary before calling normalizeHostnameInput.
- For CSV inputs, filter out empty segments to avoid stray commas tripping the empty-hostname check.
When it happens
Trigger: Calling normalizeHostnameInput(''), normalizeHostnameInput(' '), or parseHostnameCsv with a CSV containing an empty segment like 'host1,,host2'.
Common situations: A developer passes an empty string from an env var (e.g. PAPERCLIP_HOSTNAME unset yields ''). Or a config form submits a blank hostname field. Or a CSV with trailing/leading/double commas.
Related errors
- Invalid hostname: ${raw}
- Company ID is required. Pass --company-id, set PAPERCLIP_COM
- Source and target Paperclip configs are the same. Pass --fro
- Resolved worktree path ${directPath} does not contain .paper
- Resolved worktree "${selector}" does not look like a Papercl
AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12).
Data as JSON: /api/errors/dc7cf1d05bef1c7f.
Report an issue: GitHub.