{
  "id": "go/grpc-out-of-range-index-error",
  "signature": "rpc error: code = OutOfRange desc = index 10 out of bounds for list of length 5",
  "signature_zh": "rpc错误：代码=超出范围 描述=索引10超出列表长度5的范围",
  "regex": "rpc\\ error:\\ code\\ =\\ OutOfRange\\ desc\\ =\\ index\\ 10\\ out\\ of\\ bounds\\ for\\ list\\ of\\ length\\ 5",
  "domain": "go",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "Client requested an index that exceeds the size of a list or array in the response.",
  "root_cause_type": "generic",
  "root_cause_zh": "客户端请求的索引超出了响应中列表或数组的大小。",
  "versions": [
    {
      "version": "1.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Assume the server will handle out-of-range gracefully.",
      "why_fails": "The server returns an error; it does not auto-correct.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "Use negative indexing hoping it wraps around.",
      "why_fails": "Protobuf does not support negative indexing; it will still fail.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Validate the index before making the request.",
      "success_rate": 0.95,
      "how": "if idx < 0 || idx >= len(items) {\n    return fmt.Errorf(\"index out of range\")\n}\nresp, err := client.GetItem(ctx, &pb.GetRequest{Index: int32(idx)})",
      "condition": "",
      "sources": []
    },
    {
      "action": "Fetch the entire list and then access the index locally.",
      "success_rate": 0.9,
      "how": "listResp, err := client.GetList(ctx, &pb.ListRequest{})\nif err != nil { return err }\nif idx < 0 || idx >= len(listResp.Items) {\n    return fmt.Errorf(\"index out of range\")\n}\nitem := listResp.Items[idx]",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-12-10",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}