apache/druid · error · IllegalArgumentException

end metadata cannot be null

Error message

end metadata cannot be null

What it means

commitMetadataOnly() throws IllegalArgumentException when endMetadata is null. The end metadata is the new value written by the transactional update, so a null target would either NPE inside the update or wipe the metadata; the coordinator rejects it at the entry point instead.

Source

Thrown at server/src/main/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinator.java:620

  @Override
  public SegmentPublishResult commitMetadataOnly(
      String supervisorId,
      String dataSource,
      DataSourceMetadata startMetadata,
      DataSourceMetadata endMetadata
  )
  {
    if (supervisorId == null) {
      throw new IllegalArgumentException("supervisorId cannot be null");
    }
    if (dataSource == null) {
      throw new IllegalArgumentException("datasource name cannot be null");
    }
    if (startMetadata == null) {
      throw new IllegalArgumentException("start metadata cannot be null");
    }
    if (endMetadata == null) {
      throw new IllegalArgumentException("end metadata cannot be null");
    }

    try {
      return inReadWriteDatasourceTransaction(
          dataSource,
          transaction -> updateDataSourceMetadataInTransaction(
              transaction,
              supervisorId,
              dataSource,
              startMetadata,
              endMetadata
          )
      );
    }
    catch (CallbackFailedException e) {
      throw e;
    }
  }

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Always construct a concrete end metadata object (use defaults/empty collections rather than null).
  2. Assert endMetadata non-null at the call site before invoking the coordinator.
  3. Trace the metadata-producing code path to find which step returned null and fix it.

Example fix

// before
Metadata endMeta = computeNewMetadata(...); // may return null
coordinator.commitMetadataOnly(dataSource, id, startMeta, endMeta);
// after
Metadata endMeta = Optional.ofNullable(computeNewMetadata(...)).orElseGet(Metadata::new);
coordinator.commitMetadataOnly(dataSource, id, startMeta, endMeta);
Defensive patterns

Strategy: validation

Validate before calling

if (endMetadata == null) {
  throw new IllegalArgumentException("endMetadata must be provided");
}

Type guard

boolean hasEndMetadata(Metadata m) { return m != null; }

Try / catch

try {
  coordinator.commitMetadataOnly(dataSource, id, startMeta, endMeta);
} catch (IllegalArgumentException e) {
  log.error(e, "Invalid end metadata: %s", e.getMessage());
}

Prevention

When it happens

Trigger: Calling commitMetadataOnly with a null endMetadata — typically a builder or conversion step producing null metadata (e.g. empty partition/offset map turned into a null object) passed straight through.

Common situations: Custom checkpoint logic constructing the new metadata conditionally and hitting a null branch; mapping code that returns null instead of a default metadata object; version-upgrade code paths where a field was renamed and no longer populated.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/b58e232664106222. Report an issue: GitHub.