{"record":{"id":"5497b6cfd66c422b","repo":"ComposioHQ/composio","slug":"json-schema-node-depth-exceeded-cap-max-node-de","errorCode":null,"errorMessage":"JSON Schema node depth exceeded cap (${MAX_NODE_DEPTH})","messagePattern":"JSON Schema node depth exceeded cap \\((.+?)\\)","errorType":"exception","errorClass":"JsonSchemaRefResolutionError","httpStatus":null,"severity":"error","filePath":"ts/packages/core/src/utils/jsonSchema.ts","lineNumber":210,"sourceCode":"    visitedRefs: ReadonlySet<string>,\n    chainDepth: number,\n    nodeDepth: number\n  ): Record<string, unknown> =>\n    Object.fromEntries(\n      Object.entries(obj)\n        .filter(([k]) => !POLLUTING_KEYS.has(k))\n        .map(([k, v]) => [k, walk(v, visitedRefs, chainDepth, nodeDepth + 1)])\n    );\n\n  // `function` (not `const`) so `cloneChildren` above can call it via hoisting.\n  function walk(\n    node: unknown,\n    visitedRefs: ReadonlySet<string>,\n    chainDepth: number,\n    nodeDepth: number\n  ): unknown {\n    if (nodeDepth >= MAX_NODE_DEPTH) {\n      throw new JsonSchemaRefResolutionError(\n        `JSON Schema node depth exceeded cap (${MAX_NODE_DEPTH})`,\n        { possibleFixes: REF_RESOLUTION_FIXES }\n      );\n    }\n    if (Array.isArray(node)) {\n      if (visiting.has(node)) return { ...CYCLE_BREAK_SENTINEL };\n      visiting.add(node);\n      try {\n        return node.map(item => walk(item, visitedRefs, chainDepth, nodeDepth + 1));\n      } finally {\n        visiting.delete(node);\n      }\n    }\n    if (!isPlainObject(node)) return node;\n    if (visiting.has(node)) return { ...CYCLE_BREAK_SENTINEL };\n    visiting.add(node);\n    try {\n      const ref = typeof node.$ref === 'string' ? node.$ref : null;","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/core/src/utils/jsonSchema.ts#L192-L228","documentation":"walk(), which clones/dereferences schemas, caps total node depth at MAX_NODE_DEPTH to prevent stack exhaustion from deeply nested schemas. Reaching the cap throws JsonSchemaRefResolutionError with suggested fixes.","triggerScenarios":"Passing a tool schema with extremely deep property nesting (thousands of levels), sometimes generated programmatically or via recursive allOf/property chains.","commonSituations":"Machine-generated schemas (e.g. from recursive TypeScript types) or adversarial/malformed schemas from untrusted tool sources.","solutions":["Flatten or simplify the schema; remove needless wrapper objects.","If the schema comes from a tool definition you control, bound recursion when generating it.","Do not feed untrusted schemas directly; pre-validate depth before calling SDK APIs."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const depth = (v: unknown, d = 0): number =>\n  v && typeof v === 'object' ? Math.max(d, ...Object.values(v).map(x => depth(x, d + 1))) : d;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Bound recursion when generating schemas programmatically.","Reject schemas deeper than a sane limit at ingestion."],"tags":["json-schema","depth-limit","typescript"],"backgroundTag":"schema-depth-limit-exceeded","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}