# rpc error: code = OutOfRange desc = index 10 out of bounds for list of length 5

- **ID:** `go/grpc-out-of-range-index-error`
- **Domain:** go
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Client requested an index that exceeds the size of a list or array in the response.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.0 | active | — | — |
| 1.1 | active | — | — |

## Workarounds

1. **Validate the index before making the request.** (95% success)
   ```
   if idx < 0 || idx >= len(items) {
    return fmt.Errorf("index out of range")
}
resp, err := client.GetItem(ctx, &pb.GetRequest{Index: int32(idx)})
   ```
2. **Fetch the entire list and then access the index locally.** (90% success)
   ```
   listResp, err := client.GetList(ctx, &pb.ListRequest{})
if err != nil { return err }
if idx < 0 || idx >= len(listResp.Items) {
    return fmt.Errorf("index out of range")
}
item := listResp.Items[idx]
   ```

## Dead Ends

- **Assume the server will handle out-of-range gracefully.** — The server returns an error; it does not auto-correct. (100% fail)
- **Use negative indexing hoping it wraps around.** — Protobuf does not support negative indexing; it will still fail. (90% fail)
