{"record":{"id":"43e9753a18341093","repo":"apache/druid","slug":"d-0","errorCode":null,"errorMessage":"%d != 0","messagePattern":"%d != 0","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/data/SingleIndexedInt.java","lineNumber":51,"sourceCode":"  {\n  }\n\n  public void setValue(int value)\n  {\n    this.value = value;\n  }\n\n  @Override\n  public int size()\n  {\n    return 1;\n  }\n\n  @Override\n  public int get(int i)\n  {\n    if (i != 0) {\n      throw new IAE(\"%d != 0\", i);\n    }\n    return value;\n  }\n\n  @Override\n  public void inspectRuntimeShape(RuntimeShapeInspector inspector)\n  {\n    // nothing to inspect\n  }\n}\n","sourceCodeStart":33,"sourceCodeEnd":62,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/data/SingleIndexedInt.java#L33-L62","documentation":"Bounds-check guard in SingleIndexedInt.get: this IndexedInts always has exactly one element (size() == 1), so only index 0 is valid; any other index is a caller bug. The message '%d != 0' reports the offending index. It fires when a generic consumer (e.g. query result iteration code) reads SingleIndexedInt with an index other than 0, typically from a bad cursor/offset computation rather than bad data; only position 0 may be read.","triggerScenarios":"Calling get(i) with a nonzero i, usually by generic code iterating a column assuming multiple values, or applying an offset to the index.","commonSituations":"Treating a single-valued (SingleIndexedInt-backed) column like a multi-valued one; row-holder code that adds an offset (offset + i) to indexes.","solutions":["Only call get(0) on SingleIndexedInt, honoring its size()==1","Check `indexed.size()` and iterate only within it instead of assuming a fixed loop count","If you need many values, use the appropriate IndexedInts implementation rather than a single-value wrapper"],"exampleFix":"// before\nfor (int i = 0; i < numValues; i++) v = singleIndexedInt.get(i);\n// after\nfor (int i = 0; i < singleIndexedInt.size(); i++) v = singleIndexedInt.get(i);","handlingStrategy":"validation","validationCode":"assert indexed.size() == 1; int v = indexed.get(0);","typeGuard":"boolean isSingle(Indexed<?> col) { return col != null && col.size() == 1; }","tryCatchPattern":null,"preventionTips":["Check size() before indexing","Treat SingleIndexedInt as a one-element container only","Avoid offset arithmetic (base + i) on it"],"tags":["druid","segment","indexing"],"backgroundTag":"index-out-of-bounds","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}