{"record":{"id":"aa0c8e9a29c5a6ea","repo":"ComposioHQ/composio","slug":"json-schema-nesting-too-deep-to-dereference","errorCode":null,"errorMessage":"JSON Schema nesting too deep to dereference","messagePattern":"JSON Schema nesting too deep to dereference","errorType":"exception","errorClass":"JSONSchemaRefResolutionError","httpStatus":null,"severity":"error","filePath":"python/composio/utils/json_schema.py","lineNumber":251,"sourceCode":"            resolved = walk(target, next_refs, chain_depth + 1, node_depth + 1)\n\n            # Shallow-merge sibling keywords next to ``$ref`` (Draft 2020-12:\n            # siblings win on collision). Draft 7 ignores them, but the Composio\n            # tool surface admits both, so we honor siblings for safety.\n            siblings = {key: value for key, value in node.items() if key != \"$ref\"}\n            if not siblings or not _is_mapping(resolved):\n                return resolved\n            merged = dict(resolved)\n            for key, value in siblings.items():\n                merged[key] = walk(value, visited_refs, chain_depth, node_depth + 1)\n            return merged\n        finally:\n            visiting.discard(node_id)\n\n    try:\n        out = walk(root, frozenset(), 0, 0)\n    except RecursionError as exc:  # pragma: no cover - depth cap normally fires first\n        raise JSONSchemaRefResolutionError(\n            \"JSON Schema nesting too deep to dereference\"\n        ) from exc\n    if _is_mapping(out):\n        out.pop(\"$defs\", None)\n        out.pop(\"definitions\", None)\n    return out\n","sourceCodeStart":233,"sourceCodeEnd":258,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/python/composio/utils/json_schema.py#L233-L258","documentation":"dereference_json_schema caught a Python RecursionError while walking the schema — the structure was too deep to traverse even before the internal caps fired. This is a hard stop against interpreter stack exhaustion from pathological nesting.","triggerScenarios":"A schema nested deeply enough that Python's own recursion limit is hit inside walk() before MAX_NODE_DEPTH/MAX_REF_CHAIN_DEPTH trigger (e.g. when sys.setrecursionlimit was lowered, or nesting arrives via branches the caps don't count).","commonSituations":"Running inside constrained interpreters (low recursion limit, embedded hosts); adversarial or corrupted schema payloads.","solutions":["Flatten or reject the input schema","If you control the runtime and trust the schema, raise sys.setrecursionlimit — but fixing the schema is safer","Report legitimate Composio tool schemas that trigger this"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import sys\ndef safe_to_walk(schema):\n    return sys.getrecursionlimit() > 1000 and isinstance(schema, dict)","typeGuard":null,"tryCatchPattern":"from composio.exceptions import JSONSchemaRefResolutionError\ntry:\n    out = dereference_json_schema(schema)\nexcept JSONSchemaRefResolutionError:\n    out = {\"type\": \"object\", \"additionalProperties\": True}  # degrade gracefully","preventionTips":["Don't lower sys.setrecursionlimit in SDK-hosting processes","Reject absurdly nested untrusted schemas early with a depth check"],"tags":["json-schema","recursion","python"],"backgroundTag":"schema-recursion-limit-exceeded","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}