{"record":{"id":"e275420893ba04ab","repo":"apache/druid","slug":"statuscode-s-and-status-s-must-match","errorCode":null,"errorMessage":"statusCode[%s] and status[%s] must match","messagePattern":"statusCode\\[(.+?)\\] and status\\[(.+?)\\] must match","errorType":"validation","errorClass":"RE","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/indexer/TaskStatusPlus.java","lineNumber":111,"sourceCode":"      @JsonProperty(\"errorMsg\") @Nullable String errorMsg\n  )\n  {\n    if (statusCode != null && statusCode.isComplete()) {\n      Preconditions.checkNotNull(duration, \"duration\");\n    }\n    this.id = Preconditions.checkNotNull(id, \"id\");\n    this.groupId = groupId;\n    this.type = type;\n    this.createdTime = Preconditions.checkNotNull(createdTime, \"createdTime\");\n    this.queueInsertionTime = Preconditions.checkNotNull(queueInsertionTime, \"queueInsertionTime\");\n    //checks for deserialization safety\n    if (statusCode != null && status == null) {\n      this.statusCode = statusCode;\n    } else if (statusCode == null && status != null) {\n      this.statusCode = status;\n    } else {\n      if (statusCode != null && status != null && statusCode != status) {\n        throw new RE(\"statusCode[%s] and status[%s] must match\", statusCode, status);\n      }\n      this.statusCode = statusCode;\n    }\n    this.runnerTaskState = runnerTaskState;\n    this.duration = duration;\n    this.location = Preconditions.checkNotNull(location, \"location\");\n    this.dataSource = dataSource;\n    this.errorMsg = errorMsg;\n  }\n\n  @JsonProperty\n  public String getId()\n  {\n    return id;\n  }\n\n  @Nullable\n  @JsonProperty","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/indexer/TaskStatusPlus.java#L93-L129","documentation":"TaskStatusPlus accepts either a numeric statusCode or a symbolic status enum; when both are supplied they must agree. A mismatch between the two representations indicates inconsistent task status data, so a RE is thrown from the constructor.","triggerScenarios":"Constructing a TaskStatusPlus with both statusCode and status set to different values, e.g. from a JSON payload where the numeric and string fields deserialized inconsistently.","commonSituations":"REST responses to /druid/indexer/v1/tasks where the JSON contains both fields with conflicting values; custom clients caching one field and updating the other.","solutions":["Send only one of statusCode or status in the JSON payload.","Ensure both fields encode the same TaskState when both are present.","Check the client/library version that produced the payload for stale serialization logic."],"exampleFix":"// before\n{\"statusCode\": \"RUNNING\", \"status\": \"SUCCESS\"}\n// after\n{\"statusCode\": \"RUNNING\"}","handlingStrategy":"validation","validationCode":"if (json.has(\"statusCode\") && json.has(\"status\") && !json.get(\"status\").equals(TaskStatus.TaskState.fromCode(json.get(\"statusCode\")))) { throw new IllegalArgumentException(\"statusCode and status conflict\"); }","typeGuard":"TaskStatus.TaskState resolveState(Integer statusCode, TaskStatus.TaskState status) {\n  if (statusCode != null && status == null) return TaskStatus.TaskState.fromCode(statusCode);\n  if (statusCode == null && status != null) return status;\n  if (statusCode != null && status != null && statusCode != status.getCode()) throw new IllegalArgumentException(\"statusCode/status mismatch\");\n  return status;\n}","tryCatchPattern":"try { statusPlus = new TaskStatusPlus(id, ...statusCode, status, ...); } catch (RE e) { if (e.getMessage().contains(\"must match\")) { log.error(\"Inconsistent task status payload for {}\", id); } throw e; }","preventionTips":["Emit only one of statusCode/status in task-status JSON payloads","Keep client serialization of task state in sync with server","Validate task status responses before constructing TaskStatusPlus"],"tags":["task-status","inconsistent-data","validation"],"backgroundTag":"type-mismatch","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"}