{"record":{"id":"92a8301028422185","repo":"apache/druid","slug":"index-s-0","errorCode":null,"errorMessage":"Index[%s] < 0","messagePattern":"Index\\[(.+?)\\] < 0","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions-contrib/spectator-histogram/src/main/java/org/apache/druid/spectator/histogram/SpectatorHistogramIndexed.java","lineNumber":102,"sourceCode":"    offsetsHeader = NullableOffsetsHeader.read(buffer);\n    // Size is count of entries\n    size = offsetsHeader.size();\n    // The rest of the buffer is the values\n    valueBuffer = buffer.slice();\n  }\n\n  /**\n   * Checks  if {@code index} a valid `element index` in SpectatorHistogramIndexed.\n   * Similar to Preconditions.checkElementIndex() except this method throws {@link IAE} with custom error message.\n   * <p>\n   * Used here to get existing behavior(same error message and exception) of V1 GenericIndexed.\n   *\n   * @param index index identifying an element of an SpectatorHistogramIndexed.\n   */\n  private void checkIndex(int index)\n  {\n    if (index < 0) {\n      throw new IAE(\"Index[%s] < 0\", index);\n    }\n    if (index >= size) {\n      throw new IAE(\"Index[%d] >= size[%d]\", index, size);\n    }\n  }\n\n  public Class<? extends SpectatorHistogram> getClazz()\n  {\n    return strategy.getClazz();\n  }\n\n  @Override\n  public int size()\n  {\n    return size;\n  }\n\n  @Nullable","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-contrib/spectator-histogram/src/main/java/org/apache/druid/spectator/histogram/SpectatorHistogramIndexed.java#L84-L120","documentation":"checkIndex() is a validation guard invoked by get() before any buffer access. It rejects a negative element index up front so callers get the same IAE (and message) that the legacy V1 GenericIndexed produced, instead of a confusing buffer underflow later. The faulty input is the index argument passed to get().","triggerScenarios":"Thrown at extensions-contrib/spectator-histogram/src/main/java/org/apache/druid/spectator/histogram/SpectatorHistogramIndexed.java:102 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the caller that produced the index; a negative index indicates an upstream computation or offset bug","Validate indexes before calling get() when index values come from external input","If the negative index originates from internally stored offsets, report it as a possible segment-corruption or indexing bug"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}