# Error and warning codes

> Every error and warning code bytepeel reports, with what it means.

Errors are printed as `{"error":{"code":..,"message":..,"offset":..}}`, and
warnings appear in a node's `warnings` array in the same form. Codes are
stable SCREAMING_SNAKE identifiers: they are never renamed, only added.

Exit codes: `0` success, `1` decode error, `2` usage or I/O error.

| Code | Meaning |
|---|---|
| `USAGE` | Bad CLI arguments (exit 2) or MCP tool arguments |
| `IO` | File or stdin read failure (exit 2), or an MCP `output_file` that cannot be written or already exists |
| `INVALID_UTF8` | Text was required (`--in hex/base64`, `--as text`) |
| `EMPTY` | No hex digits or base64 characters |
| `INVALID_CHAR` | Not a hex digit or base64 character (offset points at it) |
| `ODD_LENGTH` | A hex token has an odd number of digits |
| `MIXED_ALPHABET` | Base64 mixes `+/` with `-_` |
| `BAD_PADDING` | Wrong `=` count, or data after padding |
| `INVALID_LENGTH` | Base64 length ≡ 1 (mod 4) |
| `PEM_UNTERMINATED` | `BEGIN` without matching `END`: an error when the first block is broken, a warning when a later block is cut off (earlier blocks are kept) |
| `TRUNCATED_VARINT` | Varint runs past the end of the buffer |
| `VARINT_OVERFLOW` | Varint exceeds 64 bits |
| `FIELD_NUMBER_ZERO` / `FIELD_NUMBER_TOO_LARGE` | Invalid protobuf field number |
| `INVALID_WIRE_TYPE` | Wire type 6 or 7 |
| `TRUNCATED_FIELD` | LEN or fixed-width field runs past the end |
| `UNEXPECTED_END_GROUP` / `UNTERMINATED_GROUP` | Group tags do not pair up |
| `NESTING_TOO_DEEP` | More than 100 nested groups, CBOR items or MessagePack items |
| `BAD_PATH` / `PATH_NOT_FOUND` / `PATH_NOT_MESSAGE` | `--get` path problems |
| `NO_PAYLOAD` | `--format raw` on a group or constructed DER element |
| `TRUNCATED_ELEMENT` | A DER element runs past the end of its container (offset at its length) |
| `INDEFINITE_LENGTH` | BER indefinite length (`0x80`); not DER |
| `BAD_LENGTH` | DER length uses more than 8 bytes |
| `BAD_TAG` | DER tag number exceeds 32 bits |
| `BAD_DUMP` | An `xxd`/`hexdump` line is out of sequence or malformed (offset at the line) |
| `CBOR_TRUNCATED` | A CBOR item runs past the end of the buffer |
| `CBOR_RESERVED` | Reserved additional information (28-30), `31` for a type that has no indefinite form, or a two-byte simple value `< 32` |
| `CBOR_BREAK` | An unexpected `0xff` break where an item was expected |
| `CBOR_BAD_UTF8` | A CBOR text string is not valid UTF-8 (offset at its content) |
| `CBOR_INVALID` | An indefinite string chunk is not a definite string of the same type |
| `MSGPACK_TRUNCATED` | A MessagePack item (or a declared length) runs past the end of the buffer |
| `MSGPACK_RESERVED` | The reserved byte `0xc1` |
| `MSGPACK_BAD_UTF8` | A MessagePack `str` is not valid UTF-8 (offset at its content) |
| Warning: `AMBIGUOUS_FORMAT` | The buffer also parses as one or more other codecs; the message names each with its confidence |
| Warning: `CORRUPT_DATA` | A gzip/zlib/zstd stream is truncated or invalid |
| Warning: `CHECKSUM_MISMATCH` | gzip CRC32, zlib Adler-32 or zstd content checksum does not match |
| Warning / error: `TOO_MANY_ITEMS` | The input needs more protobuf fields, CBOR/MessagePack values and DER elements than `--max-items` allows (an error only with `--as`) |
| Warning: `OUTPUT_TOO_LARGE` | Decompressed output would exceed 64 MiB, or the 256 MiB total budget for the input is exhausted |
| `BAD_VALUE` | A `set` value is not in the value syntax (exit 2), or does not fit the target (e.g. an invalid OID or time, or a DER insert that is not one element; exit 1) |
| `TYPE_MISMATCH` | A `set` value does not fit the field's wire type |
| `VALUE_OUT_OF_RANGE` | A `set` integer or float does not fit the field |
| `REENCODE_UNSUPPORTED` | A layer on the path cannot be re-encoded |
| `REENCODE_VERIFY_FAILED` | The re-encoded data does not decode back to the requested change |
| `ALREADY_EXISTS` | `PATH+=VALUE` names a map key that is already present |
| Warning: `NONCANONICAL_BASE64` | Unused trailing bits are set |
| Warning: `TRAILING_DATA` | Non-whitespace text outside PEM blocks (the message reports the ignored byte count), or bytes after a compressed stream, were ignored |
| Warning: `NONCANONICAL_DER` | Valid BER but not DER (non-minimal length or integer) |
| Warning: `UNSUPPORTED_FORMAT` | Recognized by magic bytes; decoder not implemented, or its Cargo feature is off |
