{"record":{"id":"62e25bf30e9525e9","repo":"apache/druid","slug":"invalid-max-row-count","errorCode":null,"errorMessage":"Invalid max row count: ","messagePattern":"Invalid max row count: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/incremental/AppendableIndexBuilder.java","lineNumber":108,"sourceCode":"    return this;\n  }\n\n  public AppendableIndexBuilder setMaxBytesInMemory(final long maxBytesInMemory)\n  {\n    this.maxBytesInMemory = maxBytesInMemory;\n    return this;\n  }\n\n  public AppendableIndexBuilder setPreserveExistingMetrics(final boolean preserveExistingMetrics)\n  {\n    this.preserveExistingMetrics = preserveExistingMetrics;\n    return this;\n  }\n\n  public void validate()\n  {\n    if (maxRowCount <= 0) {\n      throw new IllegalArgumentException(\"Invalid max row count: \" + maxRowCount);\n    }\n\n    if (incrementalIndexSchema == null) {\n      throw new IllegalArgumentException(\"incrementIndexSchema cannot be null\");\n    }\n  }\n\n  public final IncrementalIndex build()\n  {\n    log.debug(\"Building appendable index.\");\n    validate();\n    return buildInner();\n  }\n\n  protected abstract IncrementalIndex buildInner();\n}\n","sourceCodeStart":90,"sourceCodeEnd":125,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/incremental/AppendableIndexBuilder.java#L90-L125","documentation":"AppendableIndexBuilder.validate throws IllegalArgumentException when maxRowCount is <= 0, prefixing the message with 'Invalid max row count: '. An appendable index must have a positive row capacity; a non-positive value is always a configuration/builder mistake.","triggerScenarios":"Building an IncrementalIndex via the builder without calling maxRowCount(int), or explicitly setting 0/negative value, before build() invokes validate().","commonSituations":"Forgetting to set maxRowCount on a custom builder path (default 0); computing a row count from config that resolves to 0; copy-pasting builder code that omits maxRowCount.","solutions":["Call .maxRowCount(N) with N > 0 on the builder before build()","If the count comes from config, validate it is positive before constructing the builder","Use existing factory helpers (e.g. IncrementalIndexSchema-based builders) that set sane defaults"],"exampleFix":"// before\nnew IncrementalIndex.Builder().setIncrementalIndexSchema(schema).build(); // maxRowCount unset\n// after\nnew IncrementalIndex.Builder()\n    .setIncrementalIndexSchema(schema)\n    .maxRowCount(1_000_000)\n    .build();","handlingStrategy":"validation","validationCode":"if (maxRowCount <= 0) { throw new IllegalArgumentException(\"maxRowCount must be > 0, got \" + maxRowCount); }","typeGuard":null,"tryCatchPattern":"try { builder.validate(); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Invalid max row count\")) { builder.maxRowCount(DEFAULT_MAX_ROWS); } else { throw e; } }","preventionTips":["Always call maxRowCount(...) explicitly on builders","Validate config-derived row counts before builder construction","Prefer factory methods with defaults"],"tags":["java","ingestion","builder","config"],"backgroundTag":"invalid-argument-value","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}