{"record":{"id":"af5aae5345b7cc70","repo":"apache/druid","slug":"bitmapencoding-s-does-not-match-indexspec-bitmap","errorCode":null,"errorMessage":"bitmapEncoding[%s] does not match indexSpec.bitmap[%s]","messagePattern":"bitmapEncoding\\[(.+?)\\] does not match indexSpec\\.bitmap\\[(.+?)\\]","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/nested/NestedCommonFormatColumnFormatSpec.java","lineNumber":78,"sourceCode":"  /**\n   * Create a {@link NestedCommonFormatColumnFormatSpec} with all fields fully populated. Values are populated in the following order:\n   * <ul>\n   *   <li> value in the given column format spec, if non-null </li>\n   *   <li> value in {@link IndexSpec#getAutoColumnFormatSpec()}, if non-null </li>\n   *   <li> fall back to equivalent fields on {@link IndexSpec} itself if applicable </li>\n   *   <li> hard coded defaults in {@link #DEFAULT}</li>\n   * </ul>\n   */\n  public static NestedCommonFormatColumnFormatSpec getEffectiveFormatSpec(\n      @Nullable NestedCommonFormatColumnFormatSpec columnFormatSpec,\n      IndexSpec indexSpec\n  )\n  {\n    final Builder builder = columnFormatSpec == null ? builder() : builder(columnFormatSpec);\n\n    // this is a defensive check, the json spec of the column can't set this, only the builder can\n    if (builder.bitmapEncoding != null && !builder.bitmapEncoding.equals(indexSpec.getBitmapSerdeFactory())) {\n      throw new ISE(\n          \"bitmapEncoding[%s] does not match indexSpec.bitmap[%s]\",\n          builder.bitmapEncoding,\n          indexSpec.getBitmapSerdeFactory()\n      );\n    }\n    builder.setBitmapEncoding(indexSpec.getBitmapSerdeFactory());\n\n    final NestedCommonFormatColumnFormatSpec defaultSpec;\n    if (indexSpec.getAutoColumnFormatSpec() != null) {\n      defaultSpec = indexSpec.getAutoColumnFormatSpec();\n    } else {\n      defaultSpec = DEFAULT;\n    }\n\n    if (builder.longFieldBitmapIndexType == null) {\n      if (defaultSpec.getLongFieldBitmapIndexType() != null) {\n        builder.setLongFieldBitmapIndexType(defaultSpec.getLongFieldBitmapIndexType());\n      } else {","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/nested/NestedCommonFormatColumnFormatSpec.java#L60-L96","documentation":"NestedCommonFormatColumnFormatSpec.getEffectiveFormatSpec() builds the effective column format by combining the persisted columnFormatSpec with the segment indexSpec. If the builder's bitmapEncoding (which only the internal builder may set, never the JSON spec) disagrees with indexSpec.getBitmapSerdeFactory(), an internal invariant is violated and it throws an ISE.","triggerScenarios":"Deserializing a nested column format spec whose JSON contains a bitmapEncoding that conflicts with the segment metadata's indexSpec bitmap serde factory; corrupted or hand-edited segment metadata.","commonSituations":"Hand-modified or programmatically written segment metadata where bitmapEncoding was set via JSON against the documented restriction; mismatch between writer's indexSpec and column metadata after tampering or partial writes.","solutions":["Regenerate the segment: remove the offending column's formatSpec JSON so bitmapEncoding is derived solely from indexSpec.","Set indexSpec.bitmap in the ingestion spec to the same bitmap serde as any explicitly constructed builder.","Re-ingest the data to produce fresh, consistent segment metadata.","Check for external tooling writing segment descriptors directly and stop it from setting bitmapEncoding."],"exampleFix":"// before: conflicting config in ingestion spec\n// \"indexSpec\": {\"bitmap\": {\"type\": \"roaring\"}}, column format built with CONCISE bitmapEncoding\n// after: let indexSpec drive it\n// NestedCommonFormatColumnFormatSpec.builder() // do NOT call setBitmapEncoding\n//   .setBitmapEncoding(indexSpec.getBitmapSerdeFactory()).build()","handlingStrategy":"validation","validationCode":"// ensure any explicitly constructed format spec matches indexSpec before use\nif (formatSpec != null && formatSpec.getBitmapEncoding() != null &&\n    !formatSpec.getBitmapEncoding().equals(indexSpec.getBitmapSerdeFactory())) {\n  throw new IllegalArgumentException(\"bitmapEncoding must match indexSpec.bitmap\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  spec = NestedCommonFormatColumnFormatSpec.getEffectiveFormatSpec(indexSpec, columnFormatSpec, ...);\n} catch (IllegalStateException e) {\n  if (e.getMessage().contains(\"bitmapEncoding\")) {\n    log.error(e, \"Column format bitmapEncoding conflicts with indexSpec\");\n  } else throw e;\n}","preventionTips":["Never set bitmapEncoding in column format JSON; let indexSpec drive it","Keep indexSpec.bitmap consistent across ingestion and compaction specs","Avoid hand-editing segment metadata"],"tags":["druid","nested-column","configuration","index-spec","invariant"],"backgroundTag":"invalid-config-value","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"}