ruvnet/ruflo · error · Error

Key exceeds maximum nesting depth of ${MAX_NESTING_DEPTH}

Error message

Key exceeds maximum nesting depth of ${MAX_NESTING_DEPTH}

What it means

Thrown by setNestedValue in the config MCP tools when a dotted config key splits into more than 10 segments. The tool walks the dotted path to set a nested value in the config store; the depth cap prevents unbounded nesting and pathological keys. MAX_NESTING_DEPTH is fixed at 10.

Source

Thrown at v3/@claude-flow/cli/src/mcp-tools/config-tools.ts:105

}

const DANGEROUS_KEYS = new Set(['__proto__', 'constructor', 'prototype']);

function filterDangerousKeys(obj: Record<string, unknown>): Record<string, unknown> {
  const filtered: Record<string, unknown> = {};
  for (const [key, value] of Object.entries(obj)) {
    if (!DANGEROUS_KEYS.has(key)) {
      filtered[key] = value;
    }
  }
  return filtered;
}

function setNestedValue(obj: Record<string, unknown>, key: string, value: unknown): void {
  const MAX_NESTING_DEPTH = 10;
  const parts = key.split('.');
  if (parts.length > MAX_NESTING_DEPTH) {
    throw new Error(`Key exceeds maximum nesting depth of ${MAX_NESTING_DEPTH}`);
  }
  for (const part of parts) {
    if (DANGEROUS_KEYS.has(part)) {
      throw new Error(`Dangerous key segment rejected: ${part}`);
    }
  }
  let current = obj;
  for (let i = 0; i < parts.length - 1; i++) {
    const part = parts[i];
    if (!(part in current) || typeof current[part] !== 'object') {
      current[part] = {};
    }
    current = current[part] as Record<string, unknown>;
  }
  current[parts[parts.length - 1]] = value;
}

export const configTools: MCPTool[] = [

View on GitHub (pinned to 6b01dc5a68)

Solutions

  1. Reduce the dotted key to 10 or fewer segments.
  2. Flatten deeply nested config into a shorter key whose value is a JSON object.
  3. If the depth is legitimate, restructure your config schema to use fewer levels.
  4. Validate the segment count before calling config_set (split on '.' and check length <= 10).

Example fix

// before
config_set('swarm.memory.layer.a.b.c.d.e.f.g.h', value)
// after
config_set('swarm.memory.layer', { a: { b: { c: value } } })
Defensive patterns

Strategy: validation

Validate before calling

function assertConfigKeyDepth(key, max = 10) {
  const segments = key.split('.');
  if (segments.length > max) {
    throw new Error(`Key has ${segments.length} segments; max is ${max}. Flatten into an object value.`);
  }
}

Prevention

When it happens

Trigger: Calling config_set with a key like 'a.b.c.d.e.f.g.h.i.j.k' (11+ dots/segments). Each segment is one level, so 11 segments trips the > 10 check.

Common situations: A programmatically-built key that concatenates many identifiers with dots; a copy-paste of a deeply-nested JSON path; an accidental chain of namespace prefixes; user input containing dots treated as hierarchy separators.

Related errors


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