# io.ReadAtLeast: unexpected EOF

- **ID:** `go/io-read-at-least-error`
- **Domain:** go
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 88%

## Root Cause

The io.ReadAtLeast function expected to read at least N bytes from a reader, but the reader returned EOF before providing enough data, indicating a truncated or incomplete stream.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| go1.21 | active | — | — |
| go1.22 | active | — | — |
| go1.23 | active | — | — |

## Workarounds

1. **Check the data source for truncation: if reading a file, verify file size with `os.Stat` before reading; if network stream, ensure the sender transmits the full content.** (90% success)
   ```
   Check the data source for truncation: if reading a file, verify file size with `os.Stat` before reading; if network stream, ensure the sender transmits the full content.
   ```
2. **Use `io.ReadFull` instead of `io.ReadAtLeast` and handle the error gracefully, e.g., by returning a custom error or logging the incomplete read.** (85% success)
   ```
   Use `io.ReadFull` instead of `io.ReadAtLeast` and handle the error gracefully, e.g., by returning a custom error or logging the incomplete read.
   ```

## Dead Ends

- **** — The issue is not buffer size but the reader ending early; larger buffers won't help if the source is truncated. (85% fail)
- **** — The data is incomplete and may cause corruption or panics later; the error is important to handle. (90% fail)
