paperclipai/paperclip · error · ServeParseError

malformed Web key: ${JSON.stringify(key)}

Error message

malformed Web key: ${JSON.stringify(key)}

What it means

ServeParseError from portFromWebKey while parsing `tailscale serve status` output: a Web key has no usable trailing `:port` — no colon, a colon at the start, or a colon as the last character. The key shape is malformed relative to the expected host:port form.

Source

Thrown at packages/tailscale-https-broker/src/serve-config.ts:44

  entries: Map<number, ServeEntry>;
}

export class ServeParseError extends Error {
  constructor(message: string) {
    super(message);
    this.name = "ServeParseError";
  }
}

function isObject(value: unknown): value is Record<string, unknown> {
  return typeof value === "object" && value !== null && !Array.isArray(value);
}

/** Extract the trailing `:port` of a `host:port` Web key. */
function portFromWebKey(key: string): number {
  const idx = key.lastIndexOf(":");
  if (idx <= 0 || idx === key.length - 1) {
    throw new ServeParseError(`malformed Web key: ${JSON.stringify(key)}`);
  }
  const portText = key.slice(idx + 1);
  if (!/^[0-9]+$/.test(portText)) {
    throw new ServeParseError(`non-numeric port in Web key: ${JSON.stringify(key)}`);
  }
  return assertCanonicalPort(Number(portText));
}

/**
 * Parse serve status JSON into a normalized, port-keyed model. Tolerates extra
 * top-level fields (Tailscale evolves its schema) but strictly validates the
 * `TCP` and `Web` shapes it depends on.
 */
export function parseServeStatus(json: unknown): ParsedServe {
  if (!isObject(json)) {
    throw new ServeParseError("serve status must be a JSON object");
  }
  const entries = new Map<number, ServeEntry>();

View on GitHub (pinned to 120ae5428f)

Solutions

  1. Fix the Web key format in the tailscale serve config; it must match the expected host/port key shape.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/tailscale-https-broker/src/serve-config.ts:44 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of paperclipai/paperclip@120ae5428f (2026-08-18). Data as JSON: /api/errors/5fa1c7498b41e71f. Report an issue: GitHub.