{"record":{"id":"e0d70e4865a85ebc","repo":"apache/druid","slug":"could-not-convert-task-s-to-compatible-object","errorCode":null,"errorMessage":"Could not convert task[%s] to compatible object.","messagePattern":"Could not convert task\\[(.+?)\\] to compatible object\\.","errorType":"exception","errorClass":"DruidException","httpStatus":null,"severity":"error","filePath":"indexing-service/src/main/java/org/apache/druid/indexing/compact/LocalOverlordClient.java","lineNumber":190,"sourceCode":"  {\n    if (taskPayload == null) {\n      return null;\n    } else if (!inputType.isInstance(taskPayload)) {\n      throw DruidException.defensive(\n          \"Unknown type[%s] for compaction task. Expected type[%s].\",\n          taskPayload.getClass().getSimpleName(), inputType.getSimpleName()\n      );\n    }\n\n    try {\n      return objectMapper.readValue(\n          objectMapper.writeValueAsBytes(taskPayload),\n          outputType\n      );\n    }\n    catch (IOException e) {\n      log.warn(e, \"Could not convert task[%s] to client compatible object\", taskPayload);\n      throw DruidException.defensive(\n          \"Could not convert task[%s] to compatible object.\",\n          taskPayload\n      );\n    }\n  }\n}\n","sourceCodeStart":172,"sourceCodeEnd":197,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/indexing-service/src/main/java/org/apache/druid/indexing/compact/LocalOverlordClient.java#L172-L197","documentation":"LocalOverlordClient.convertTask() fails when Jackson cannot deserialize/serialize the task payload into the requested outputType (client-compatible object). On IOException it logs a warning and throws a defensive DruidException 'Could not convert task[%s] to compatible object.', indicating an internal invariant violation since task payloads should be convertible.","triggerScenarios":"task/taskPayload call encountering an IOException from objectMapper.readValue(taskJson, outputType) — e.g. task JSON incompatible with the expected type or missing modules.","commonSituations":"Custom task types not registered with the ObjectMapper (missing module/ subtype registration); corrupted or hand-edited task payloads in metadata storage; version skew between overlord and client task classes.","solutions":["Ensure the task's type is registered in the injector's polymorphic ObjectMapper (register the task module/subtypes).","Inspect the task payload in the metadata storage for corruption or schema drift.","Align versions of indexing-service classes between writer and reader of the payload.","File a bug if the payload is a standard Druid task type, since this is a defensive invariant failure."],"exampleFix":"// before\n// Custom task class not registered -> convertTask throws DruidException\n// after\n// register the subtype so Jackson can map it\nobjectMapper.registerSubtypes(MyCustomTask.class);","handlingStrategy":"try-catch","validationCode":"// Before querying, confirm the task type is registered\nif (!knownTaskTypes.contains(task.getType())) { throw new IllegalArgumentException(\"Unknown task type: \" + task.getType()); }","typeGuard":null,"tryCatchPattern":"try { Task t = client.task(taskId); } catch (DruidException e) { if (e.getMessage().contains(\"Could not convert task\")) { /* inspect payload / register subtype */ } }","preventionTips":["Register all custom task subtypes with the ObjectMapper","Avoid hand-editing task payloads in metadata storage","Keep overlord and client class versions aligned"],"tags":["json","serialization","task","overlord"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}