can1357/oh-my-pi · error · Error

${parsed.error}

Error message

${parsed.error}

What it means

The CollabGuest constructor parses a collaboration invite link via parseCollabLink; if the link is malformed the parser returns an error object and the constructor throws a plain Error with the parser's message. Since constructors throw, an invalid link can never produce a guest instance.

Source

Thrown at packages/collab-web/src/lib/client.ts:126

	#entries: readonly SessionEntry[] = [];
	#state: SessionState | null = null;
	#agents: readonly AgentSnapshot[] = [];
	#progress: ReadonlyMap<string, SubagentProgressPayload> = new Map();
	#lifecycle: ReadonlyMap<string, SubagentLifecyclePayload> = new Map();
	#stream: AssistantMessage | null = null;
	#streamDone = false;
	#activeTools: ReadonlyMap<string, ActiveTool> = new Map();
	#working = false;
	#readOnly = false;
	#uiRequest: CollabUiRequest | null = null;
	#uiRequestQueue: CollabUiRequest[] = [];
	#notices: readonly Notice[] = [];
	#snapshot: GuestSnapshot;

	/** @throws Error when the link does not parse. */
	constructor(link: string, displayName: string) {
		const parsed = parseCollabLink(link);
		if ("error" in parsed) throw new Error(parsed.error);
		this.#name = displayName;
		this.#writeToken = parsed.writeToken ? encodeBase64Url(parsed.writeToken) : undefined;
		this.#socket = new CollabSocket({ wsUrl: parsed.wsUrl, role: "guest", key: importRoomKey(parsed.key) });
		this.#socket.onOpen = () => this.#handleOpen();
		this.#socket.onFrame = frame => this.#applyFrameSafe(frame);
		this.#socket.onControl = msg => {
			if (msg.t === "room-closed") this.#end("room closed");
		};
		this.#socket.onClose = (reason, willReconnect) => this.#handleClose(reason, willReconnect);
		this.#snapshot = this.#buildSnapshot();
	}

	connect(): void {
		if (this.#phase === "ended") {
			this.#phase = "connecting";
			this.#endedReason = null;
			this.#commit();
		}

View on GitHub (pinned to 9690622007)

Solutions

  1. Re-copy the full invite link from the source without truncation
  2. Validate the link with parseCollabLink before constructing and show a user-friendly message on error
  3. Ensure the link was generated by formatCollabLink on the host side with matching relay format
  4. Check for a version mismatch between the link generator and client codec formats

Example fix

// before
const guest = new CollabGuest(link, name); // throws on bad link
// after
const parsed = parseCollabLink(link);
if (!("error" in parsed)) {
  const guest = new CollabGuest(link, name);
} else {
  showError("Invalid collaboration link: " + parsed.error);
}
Defensive patterns

Strategy: validation

Validate before calling

const parsed = parseCollabLink(link);
if ("error" in parsed) {
  throw new Error("Invalid collaboration link: " + parsed.error);
}

Type guard

function isValidCollabLink(
  parsed: ReturnType<typeof parseCollabLink>,
): parsed is Exclude<ReturnType<typeof parseCollabLink>, { error: string }> {
  return !("error" in parsed);
}

Try / catch

try {
  const guest = new CollabGuest(link, displayName);
} catch (e) {
  showUserError("This invite link is invalid or incomplete. Please re-copy the full link.");
}

Prevention

When it happens

Trigger: Constructing CollabGuest (or the guest client) with a collab link string that fails parsing: wrong base64url key segment, missing roomId, bad relay URL, truncated or hand-edited link.

Common situations: Users copy-pasting invite URLs and truncating them, chat apps wrapping URLs and breaking them, manually constructing links with wrong encoding, or links from an older relay format.

Related errors


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