{"record":{"id":"2615dda951d4add2","repo":"apache/druid","slug":"datasource-name-cannot-be-null","errorCode":null,"errorMessage":"datasource name cannot be null","messagePattern":"datasource name cannot be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinator.java","lineNumber":614,"sourceCode":"        endMetadata,\n        taskAllocatorId,\n        segmentSchemaMapping\n    );\n  }\n\n  @Override\n  public SegmentPublishResult commitMetadataOnly(\n      String supervisorId,\n      String dataSource,\n      DataSourceMetadata startMetadata,\n      DataSourceMetadata endMetadata\n  )\n  {\n    if (supervisorId == null) {\n      throw new IllegalArgumentException(\"supervisorId cannot be null\");\n    }\n    if (dataSource == null) {\n      throw new IllegalArgumentException(\"datasource name cannot be null\");\n    }\n    if (startMetadata == null) {\n      throw new IllegalArgumentException(\"start metadata cannot be null\");\n    }\n    if (endMetadata == null) {\n      throw new IllegalArgumentException(\"end metadata cannot be null\");\n    }\n\n    try {\n      return inReadWriteDatasourceTransaction(\n          dataSource,\n          transaction -> updateDataSourceMetadataInTransaction(\n              transaction,\n              supervisorId,\n              dataSource,\n              startMetadata,\n              endMetadata\n          )","sourceCodeStart":596,"sourceCodeEnd":632,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinator.java#L596-L632","documentation":"commitMetadataOnly() in IndexerSQLMetadataStorageCoordinator updates a supervisor's stored metadata (e.g. checkpoint offsets) inside a read-write transaction. Before opening the transaction it validates its arguments and throws IllegalArgumentException when the datasource name is null, because datasource metadata rows are keyed by the datasource and a null key is meaningless. This is a caller-side programming error, not a transient failure.","triggerScenarios":"Calling commitMetadataOnly(dataSource, supervisorId, startMetadata, endMetadata) with a null first argument — typically when the supervisor spec's dataSource field was never populated or was deserialized as null before the call.","commonSituations":"A custom supervisor implementation passes a spec whose getDataSource() returns null; external tooling invoking the coordinator directly with a partially constructed spec; unit-test code forgetting to set the datasource on a SupervisorSpec mock.","solutions":["Ensure the SupervisorSpec has a non-null dataSource before calling commitMetadataOnly.","Add a caller-side null/empty check on dataSource and fail fast with a descriptive message.","Inspect how the spec was deserialized (JSON payload missing 'dataSource') and fix the input payload or deserializer."],"exampleFix":"// before\ncoordinator.commitMetadataOnly(spec.getDataSource(), spec.getId(), startMeta, endMeta);\n// after\nString dataSource = Preconditions.checkNotNull(spec.getDataSource(), \"dataSource\");\ncoordinator.commitMetadataOnly(dataSource, spec.getId(), startMeta, endMeta);","handlingStrategy":"validation","validationCode":"if (dataSource == null || dataSource.isEmpty()) {\n  throw new IllegalArgumentException(\"dataSource must be non-null before commitMetadataOnly\");\n}","typeGuard":"boolean hasDataSource(SupervisorSpec spec) { return spec.getDataSource() != null && !spec.getDataSource().isEmpty(); }","tryCatchPattern":"try {\n  coordinator.commitMetadataOnly(dataSource, id, startMeta, endMeta);\n} catch (IllegalArgumentException e) {\n  log.error(e, \"Supervisor metadata commit rejected: %s\", e.getMessage());\n}","preventionTips":["Always derive the datasource from a validated spec object","Add unit tests covering specs with missing dataSource fields","Validate deserialized specs at ingestion boundaries"],"tags":["metadata","null-argument","supervisor"],"backgroundTag":"null-argument","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"}