Sanity limits on a document read from elsewhere (spec/01 §5).
| Limit | Default | Bounds |
|---|---|---|
bytes | 8_000_000 | the encoded document's size |
depth | 64 | how deeply objects and arrays nest; the document itself is depth 1 |
items | 100_000 | the entries any one object or array holds |
They bound what reading a document can be made to cost. A host may tighten every limit, never loosen one: a host loading untrusted input knows its inputs and lowers the numbers at its layer, and a limit it does not name keeps its default.
A fault is {path, {:limit, name, max, given}}, worded by Macaw.Layers.Fault.format/2.
The walk over a decoded term is the generic part of visualize's
Visualize.Chart.Limits.structure/2.
Summary
Functions
The system's sanity values.
The limits a reader applies: given over defaults/0.
Every depth and items fault of a decoded term, ordered by path.
Types
@type name() :: :bytes | :depth | :items
A limit's name.
@type t() :: %{required(name()) => pos_integer()}
The limits a reader applies, one positive integer per name.
Functions
@spec defaults() :: t()
The system's sanity values.
The limits a reader applies: given over defaults/0.
Raises ArgumentError for a name that is not a limit, a value that is not a positive
integer, or one above the default: a host can't loosen a sanity limit by mistake.
iex> Macaw.Layers.Limits.new(items: 10).items
10
@spec structure(term(), t()) :: [Macaw.Layers.Fault.t()]
Every depth and items fault of a decoded term, ordered by path.
The term itself is depth 1. A struct is a leaf. Past the depth limit a branch is reported once, at the first map or list beyond it, and not walked further. A map or list over the items limit is reported at its own path, with the number of entries it holds.