Skip to main content

MAX_DEPTH

Constant MAX_DEPTH 

Source
pub const MAX_DEPTH: usize = 64;
Expand description

How deeply arrays and objects may nest before parsing is refused.

Recursive descent uses stack in proportion to nesting, and a stack overflow in Rust is an abort rather than an error: nothing unwinds and no caller can recover. Before this limit existed, two kilobytes of [[[[...]]]] ended the process – which matters because ic mcp parses JSON-RPC from whatever is on the other end of its stdin.

64 is chosen against measurement rather than taste. The deepest document this project produces is the JSON Schema export, at 7; JSON-LD reaches 5 and the SBOM 6. That is an order of magnitude of headroom, and far below the roughly one thousand that exhausts the stack.