{"record":{"id":"f558213540c14252","repo":"ruvnet/ruflo","slug":"key-exceeds-maximum-nesting-depth-of-max-nesting","errorCode":null,"errorMessage":"Key exceeds maximum nesting depth of ${MAX_NESTING_DEPTH}","messagePattern":"Key exceeds maximum nesting depth of (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/mcp-tools/config-tools.ts","lineNumber":105,"sourceCode":"}\n\nconst DANGEROUS_KEYS = new Set(['__proto__', 'constructor', 'prototype']);\n\nfunction filterDangerousKeys(obj: Record<string, unknown>): Record<string, unknown> {\n  const filtered: Record<string, unknown> = {};\n  for (const [key, value] of Object.entries(obj)) {\n    if (!DANGEROUS_KEYS.has(key)) {\n      filtered[key] = value;\n    }\n  }\n  return filtered;\n}\n\nfunction setNestedValue(obj: Record<string, unknown>, key: string, value: unknown): void {\n  const MAX_NESTING_DEPTH = 10;\n  const parts = key.split('.');\n  if (parts.length > MAX_NESTING_DEPTH) {\n    throw new Error(`Key exceeds maximum nesting depth of ${MAX_NESTING_DEPTH}`);\n  }\n  for (const part of parts) {\n    if (DANGEROUS_KEYS.has(part)) {\n      throw new Error(`Dangerous key segment rejected: ${part}`);\n    }\n  }\n  let current = obj;\n  for (let i = 0; i < parts.length - 1; i++) {\n    const part = parts[i];\n    if (!(part in current) || typeof current[part] !== 'object') {\n      current[part] = {};\n    }\n    current = current[part] as Record<string, unknown>;\n  }\n  current[parts[parts.length - 1]] = value;\n}\n\nexport const configTools: MCPTool[] = [","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/ruvnet/ruflo/blob/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/v3/@claude-flow/cli/src/mcp-tools/config-tools.ts#L87-L123","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Reduce the dotted key to 10 or fewer segments.","Flatten deeply nested config into a shorter key whose value is a JSON object.","If the depth is legitimate, restructure your config schema to use fewer levels.","Validate the segment count before calling config_set (split on '.' and check length <= 10)."],"exampleFix":"// before\nconfig_set('swarm.memory.layer.a.b.c.d.e.f.g.h', value)\n// after\nconfig_set('swarm.memory.layer', { a: { b: { c: value } } })","handlingStrategy":"validation","validationCode":"function assertConfigKeyDepth(key, max = 10) {\n  const segments = key.split('.');\n  if (segments.length > max) {\n    throw new Error(`Key has ${segments.length} segments; max is ${max}. Flatten into an object value.`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Split candidate keys on '.' and assert segment count before config_set.","Prefer object values over very deep dotted keys.","Cap programmatically-built keys at a fixed depth."],"tags":["config","mcp-tools","validation","nested-key","input-validation"],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}