> For the complete documentation index, see [llms.txt](https://docs.internetobject.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.internetobject.org/parsing-and-errors/error-accumulation.md).

# Error Accumulation

Accumulating per-object validation errors and per-region syntax errors.

Rather than stopping at the first problem, a conformant processor **accumulates** errors and returns them together, alongside whatever data parsed successfully. This gives authors a full picture in one pass.

## Per-object validation errors

Each record is validated independently and may contribute **zero, one, or many** errors. A failing record is marked as an error; the others are unaffected:

```ruby
~ $schema: { name: string, age: { int, max: 25 } }
---
~ James, 20    # ✓
~ Alex, 30     # ✗ mismatched-max
~ Bob, 22      # ✓
```

The result contains two valid records and one error entry — not a single fatal failure.

## Per-region syntax errors

Syntax errors are accumulated per recovered region (between boundaries). One unparsable record yields one error, and parsing resumes at the next `~` or `---`.

## Partial output

Because errors are accumulated rather than thrown, the loaded result includes the records that succeeded. Consumers can render valid data and surface the error list side by side (for example, editor markers at each error's position).

## Duplicate section names

When two sections share a name, the duplicate is **automatically renamed** so the rest of the document still loads. A recovering parser **MUST NOT** drop a section, and **MUST NOT** let one overwrite another: either would lose data with nothing to show for it.

The renaming rule, stated exactly, because two implementations that disagree here produce differently-named sections from the same document:

> On encountering a section whose name is already in use, append `_2` to the **original** name. If that name is also in use, try `_3`, then `_4`, and so on, until an unused name is found. The counter is **per name**, not per document, and it counts *names already taken* — including names a later section spelled out for itself.

So a document with three `users` sections yields `users`, `users_2`, `users_3`; and a document with sections named `a`, `b`, `a`, `b` yields `a`, `b`, `a_2`, `b_2` — not `a_2`, `b_3`.

Because the rule counts names already taken, an explicit name cannot be silently displaced:

```
--- users        → users
--- users_2      → users_2   (written that way by the author)
--- users        → users_3   (skips users_2, which is taken)
```

This applies to sections that carry no name of their own, too: they take the default name `data`, so three unnamed sections become `data`, `data_2`, `data_3`.

The document is still invalid: [section names must be unique](/structure-and-syntax/introduction/data.md#rules-for-section-names-and-schemas), and the error is reported alongside the recovered data. The error is `duplicate-section-name` — a **structural** fault, not a lexical one, since every character in the document is valid.

## See Also

* [Error Codes](/parsing-and-errors/error-codes.md) · [Error Model](/parsing-and-errors/error-model.md) · [Parser Behavior & Recovery](/parsing-and-errors/parser-behavior.md)
* [Collection Rules](/collections/collection-rules.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.internetobject.org/parsing-and-errors/error-accumulation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
