ruvnet/ruflo · error · Error

The sibling message doesn't exist

Error message

The sibling message doesn't exist

What it means

Thrown by addSibling when conv.messages.find(m => m.id === siblingId) returns undefined. The sibling is the reference point whose ancestors the new node will share, so an unknown siblingId cannot be resolved.

Source

Thrown at ruflo/src/ruvocal/src/lib/utils/tree/addSibling.ts:15

import { v4 } from "uuid";
import type { Tree, TreeId, NewNode, TreeNode } from "./tree";

export function addSibling<T>(conv: Tree<T>, message: NewNode<T>, siblingId: TreeId): TreeId {
	if (conv.messages.length === 0) {
		throw new Error("Cannot add a sibling to an empty conversation");
	}
	if (!conv.rootMessageId) {
		throw new Error("Cannot add a sibling to a legacy conversation");
	}

	const sibling = conv.messages.find((m) => m.id === siblingId);

	if (!sibling) {
		throw new Error("The sibling message doesn't exist");
	}

	if (!sibling.ancestors || sibling.ancestors?.length === 0) {
		throw new Error("The sibling message is the root message, therefore we can't add a sibling");
	}

	const messageId = v4();

	conv.messages.push({
		...message,
		id: messageId,
		ancestors: sibling.ancestors,
		children: [],
	} as TreeNode<T>);

	const nearestAncestorId = sibling.ancestors[sibling.ancestors.length - 1];
	const nearestAncestor = conv.messages.find((m) => m.id === nearestAncestorId);

View on GitHub (pinned to 6b01dc5a68)

Solutions

  1. Look up the siblingId in conv.messages before calling addSibling; if absent, refetch the conversation.
  2. Ensure the id you pass is the server-persisted id, not a client placeholder.
  3. Trim/normalise id strings before lookup.

Example fix

// before
addSibling(conv, message, siblingId);
// after
if (!conv.messages.some((m) => m.id === siblingId)) {
  throw new Error(`sibling ${siblingId} not in conversation ${conv.id ?? "?"}`);
}
addSibling(conv, message, siblingId);
Defensive patterns

Strategy: validation

Validate before calling

const sibling = conv.messages.find((m) => m.id === siblingId);
if (!sibling) {
  throw new Error(`sibling ${siblingId} not found in conversation`);
}
addSibling(conv, message, siblingId);

Type guard

function hasMessage<T>(conv: Tree<T>, id: string): boolean {
  return conv.messages.some((m) => m.id === id);
}

Prevention

When it happens

Trigger: Passing a stale siblingId (deleted message, id from a different conversation, a client-generated id that was never persisted), or a typo in the id.

Common situations: Optimistic UI that creates a local id then calls addSibling before the server-issued id is known; the sibling message was deleted in another tab; a copy-paste of an id with trailing whitespace.

Related errors


AI-assisted analysis of ruvnet/ruflo@6b01dc5a68 (2026-08-12). Data as JSON: /api/errors/fac3ddf9258ca982. Report an issue: GitHub.