> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nika.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# on_error

> Contract, placement, related fields and source examples for this Nika YAML field.

[Language reference](https://docs.nika.sh/reference/language/overview.md) / `on_error`

## Meaning and placement

### task

The schema declares this field at the location below.

| Property | Declaration |
| - | - |
| Requirement | Optional in this object |
| Schema location | `/$defs/task/properties/on_error` |
| \$ref | `"#/$defs/onError"` |

**In the same object:** [after](https://docs.nika.sh/reference/language/words/after.md) · [agent](https://docs.nika.sh/reference/language/words/agent.md) · [exec](https://docs.nika.sh/reference/language/words/exec.md) · [extract](https://docs.nika.sh/reference/language/words/extract.md) · [for\_each](https://docs.nika.sh/reference/language/words/for_each.md) · [group](https://docs.nika.sh/reference/language/words/group.md) · [infer](https://docs.nika.sh/reference/language/words/infer.md) · [invoke](https://docs.nika.sh/reference/language/words/invoke.md) · [lift](https://docs.nika.sh/reference/language/words/lift.md) · [retry](https://docs.nika.sh/reference/language/words/retry.md) · [returns](https://docs.nika.sh/reference/language/words/returns.md) · [timeout](https://docs.nika.sh/reference/language/words/timeout.md) · [when](https://docs.nika.sh/reference/language/words/when.md) · [with](https://docs.nika.sh/reference/language/words/with.md)

[Schema source (use the pointer above)](https://github.com/supernovae-st/nika-spec/blob/4e259e5b8012fcdf92f094142a52dfef24099b85/schemas/workflow.schema.json)

## In a source template

Excerpt from `templates/api-upload-and-create.nika`, source lines 80–89. This is a fragment, not a runnable workflow.

```yaml illustration theme={"system"}
          - { name: title, value: "Rehearsal item" }   # SLOT: the metadata fields
        mode: jq
        jq: "{ id: .id, url: .url }"   # SLOT: the fields downstream needs
    on_error:
      # The rehearsal, NARROWED to the one thing it may forgive: the key is
      # not configured. A `secrets:` entry whose env var is unset fails
      # NIKA-VAR-001 before any byte leaves (measured on 0.118.7 · the run
      # settles « 1 recovered » on that code) — that absence IS the rehearsal
      # switch. Everything else stays loud: a wired key the API rejects is
      # NIKA-BUILTIN-FETCH-001 naming the 401 (measured), a dead endpoint too.
```

### Templates containing this field

| Template | Source |
| - | - |
| `templates/api-upload-and-create.nika` | [Line 83](https://github.com/supernovae-st/nika-spec/blob/4e259e5b8012fcdf92f094142a52dfef24099b85/templates/api-upload-and-create.nika#L83) |
| `templates/chain.nika` | [Line 50](https://github.com/supernovae-st/nika-spec/blob/4e259e5b8012fcdf92f094142a52dfef24099b85/templates/chain.nika#L50) |
| `templates/docker-report.nika` | [Line 53](https://github.com/supernovae-st/nika-spec/blob/4e259e5b8012fcdf92f094142a52dfef24099b85/templates/docker-report.nika#L53) |
| `templates/etl-state.nika` | [Line 80](https://github.com/supernovae-st/nika-spec/blob/4e259e5b8012fcdf92f094142a52dfef24099b85/templates/etl-state.nika#L80) |
| `templates/fanout.nika` | [Line 101](https://github.com/supernovae-st/nika-spec/blob/4e259e5b8012fcdf92f094142a52dfef24099b85/templates/fanout.nika#L101) |
| `templates/gate-and-act.nika` | [Line 60](https://github.com/supernovae-st/nika-spec/blob/4e259e5b8012fcdf92f094142a52dfef24099b85/templates/gate-and-act.nika#L60) |
| `templates/human-gated-ship.nika` | [Line 99](https://github.com/supernovae-st/nika-spec/blob/4e259e5b8012fcdf92f094142a52dfef24099b85/templates/human-gated-ship.nika#L99) |
| `templates/media-asset-pack.nika` | [Line 78](https://github.com/supernovae-st/nika-spec/blob/4e259e5b8012fcdf92f094142a52dfef24099b85/templates/media-asset-pack.nika#L78) |
| `templates/recover-optional-file.nika` | [Line 35](https://github.com/supernovae-st/nika-spec/blob/4e259e5b8012fcdf92f094142a52dfef24099b85/templates/recover-optional-file.nika#L35) |
| `templates/website-brief.nika` | [Line 53](https://github.com/supernovae-st/nika-spec/blob/4e259e5b8012fcdf92f094142a52dfef24099b85/templates/website-brief.nika#L53) |

These are literal key occurrences in the source files, not an execution or conformance claim. [How to instantiate a template](https://docs.nika.sh/guides/templates.md).

## Contract and implementation

This page projects the named specification revision. Check [released engine status](https://docs.nika.sh/reference/status.md) and [the validation workflow](https://docs.nika.sh/guides/agent-authoring.md) before running a file. An optional field is not evidence that every engine supports every value.

Canonical identity: `language:word:on_error`. Spec revision: [`4e259e5b8012`](https://github.com/supernovae-st/nika-spec/tree/4e259e5b8012fcdf92f094142a52dfef24099b85).

[How documentation stays connected](https://docs.nika.sh/reference/knowledge-system.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.