## TL;DR

Secret parsers expect text; binary files crash them. Detect binaries up front with a content check, skip them (or scan them as opaque blobs), and never feed raw binary to a text parser.

## Error

```text
agent failed to handle binary files: parser crashed with error
```

## Steps

1. Identify the crashing file and confirm it is binary. Expected: the trigger file found.
2. Add a binary check before parsing: inspect the first bytes for nulls or use a file-type check. Expected: binaries detected reliably.
3. Skip binaries in text parsers; optionally hash them for change detection. Expected: no more crashes.
4. For formats that embed text (archives, documents), extract text first with the right tool, then parse the text. Expected: coverage without crashes.
5. Re-run the scan over the previously crashing input. Expected: clean completion.

## When to use

- Parser crashes on binary files.
- Hardening scan agents.

## When not to use

- Crashes on text files (different bug).
- You need secrets inside binaries (extract text first).

## Tool compatibility

- File-type detection; streaming parsers.

## Variant phrasings

### parser crashed on binary

Check before parsing.

### binary file broke the scan

Skip or extract.

## Why it happens

Text parsers assume decodable input; binary bytes violate that and crash decoders or regex engines.

## Edge cases

- Mixed files (text with binary blobs) need chunk-wise handling.
- Encoding detection can mislabel; prefer null-byte heuristics.
- Skipped binaries should be logged so coverage gaps are visible.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_aknsWXLtZmj6wi0S8wZ-VA
