{"record":{"id":"cc5ed6983df866c8","repo":"apache/druid","slug":"start-metadata-cannot-be-null","errorCode":null,"errorMessage":"start metadata cannot be null","messagePattern":"start metadata cannot be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinator.java","lineNumber":617,"sourceCode":"    );\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          )\n      );\n    }\n    catch (CallbackFailedException e) {","sourceCodeStart":599,"sourceCodeEnd":635,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinator.java#L599-L635","documentation":"commitMetadataOnly() atomically moves a supervisor's metadata from a start value to an end value. It validates all arguments up front and throws IllegalArgumentException when startMetadata is null, because the transactional compare-and-set needs a concrete starting metadata value to match against.","triggerScenarios":"Calling commitMetadataOnly with a null startMetadata — e.g. reading the current metadata, getting null (supervisor metadata absent in the store), and passing it straight back in.","commonSituations":"A supervisor checkpoints before its metadata row was ever created; concurrent delete of supervisor metadata between read and commit; test harness supplying null metadata placeholders.","solutions":["Fetch the current metadata first and only call commitMetadataOnly when it is non-null (create it if missing via the appropriate insert path).","Handle the 'no metadata yet' case in the caller rather than forwarding null.","Verify the supervisor id/datasource actually exist in the metadata store before committing."],"exampleFix":"// before\ncoordinator.commitMetadataOnly(dataSource, id, currentMeta, newMeta); // currentMeta may be null\n// after\nif (currentMeta != null) {\n  coordinator.commitMetadataOnly(dataSource, id, currentMeta, newMeta);\n} else {\n  insertInitialMetadata(dataSource, id, newMeta);\n}","handlingStrategy":"validation","validationCode":"if (startMetadata == null) {\n  // metadata not yet created; handle before committing\n  throw new IllegalStateException(\"No existing supervisor metadata to move from\");\n}","typeGuard":"boolean hasStartMetadata(Metadata m) { return m != null; }","tryCatchPattern":"try {\n  coordinator.commitMetadataOnly(dataSource, id, startMeta, endMeta);\n} catch (IllegalArgumentException e) {\n  log.error(e, \"Cannot commit supervisor metadata: %s\", e.getMessage());\n  // create metadata row or re-fetch current state\n}","preventionTips":["Always read current metadata via the coordinator before attempting a move","Treat null reads as 'not initialized' and initialize instead of committing","Handle concurrent supervisor deletions with re-reads"],"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"}