ruvnet/ruflo · error · Error

Hierarchy must have at least one node

Error message

Hierarchy must have at least one node

What it means

validateHierarchy() found the hierarchy's node list empty. Embedding an empty hierarchy is meaningless, so the guard fires before any hyperbolic embedding work; supply a hierarchy with at least one node.

Source

Thrown at v3/plugins/hyperbolic-reasoning/src/bridges/hyperbolic-bridge.ts:403

    // Sort by distance and take top k
    results.sort((a, b) => a.distance - b.distance);
    const topK = results.slice(0, k);

    return {
      items: topK,
      totalCandidates: results.length,
      searchTimeMs: performance.now() - startTime,
    };
  }

  // ============================================================================
  // Private Helper Methods
  // ============================================================================

  private validateHierarchy(hierarchy: Hierarchy): void {
    if (hierarchy.nodes.length === 0) {
      throw new Error('Hierarchy must have at least one node');
    }

    if (hierarchy.nodes.length > 1_000_000) {
      throw new Error('Hierarchy exceeds maximum size of 1M nodes');
    }

    // Check for cycles
    const visited = new Set<string>();
    const inStack = new Set<string>();

    const hasCycle = (nodeId: string): boolean => {
      if (inStack.has(nodeId)) return true;
      if (visited.has(nodeId)) return false;

      visited.add(nodeId);
      inStack.add(nodeId);

      const node = hierarchy.nodes.find(n => n.id === nodeId);

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Provide a hierarchy containing at least one node before embedding.
  2. Validate input size up front and return an empty-result status instead of throwing for empty input, if that is acceptable.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at v3/plugins/hyperbolic-reasoning/src/bridges/hyperbolic-bridge.ts:403 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/9b6eb7547b1df52e. Report an issue: GitHub.