{"record":{"id":"2a5630632112346b","repo":"flowable/flowable-engine","slug":"batch-part-with-id-batchpartid-does-not-have","errorCode":null,"errorMessage":"Batch part with id '${batchPartId}' does not have a batch part document.","messagePattern":"Batch part with id '(.+?)' does not have a batch part document\\.","errorType":"http","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/management/BatchPartResource.java","lineNumber":67,"sourceCode":"    @GetMapping(value = \"/management/batch-parts/{batchPartId}\", produces = \"application/json\")\n    public BatchPartResponse getBatchPart(@ApiParam(name = \"batchPartId\") @PathVariable String batchPartId) {\n        BatchPart batchPart = getBatchPartById(batchPartId);\n        return restResponseFactory.createBatchPartResponse(batchPart);\n    }\n    \n    @ApiOperation(value = \"Get the batch part document\", tags = { \"Batches\" })\n    @ApiResponses(value = {\n            @ApiResponse(code = 200, message = \"Indicates the requested batch part was found and the batch part document has been returned. The response contains the raw batch part document and always has a Content-type of application/json.\"),\n            @ApiResponse(code = 404, message = \"Indicates the requested batch part was not found or the job does not have a batch part document. Status-description contains additional information about the error.\")\n    })\n    @GetMapping(\"/management/batch-parts/{batchPartId}/batch-part-document\")\n    public String getBatchPartDocument(@ApiParam(name = \"batchPartId\") @PathVariable String batchPartId, HttpServletResponse response) {\n        BatchPart batchPart = getBatchPartById(batchPartId);\n\n        String batchPartDocument = managementService.getBatchPartDocument(batchPartId);\n\n        if (batchPartDocument == null) {\n            throw new FlowableObjectNotFoundException(\"Batch part with id '\" + batchPart.getId() + \"' does not have a batch part document.\", String.class);\n        }\n\n        response.setContentType(\"application/json\");\n        return batchPartDocument;\n    }\n}\n","sourceCodeStart":49,"sourceCodeEnd":74,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/management/BatchPartResource.java#L49-L74","documentation":"GET /management/batch-parts/{batchPartId}/content returns the batch part's stored document via managementService.getBatchPartDocument. The batch part row exists (getBatchPartById succeeded), but its document column is null, so the controller throws FlowableObjectNotFoundException typed to String.class. Flowable stores no document for batch parts unless one was set when the batch was created/started.","triggerScenarios":"Requesting the document of a batch part that was never given a document (e.g. a batch started without a batch document, or a part type that carries no payload).","commonSituations":"Custom batch types created without a document; assuming every part has JSON content; copying document-fetch logic from batch to batch-part where only the batch has a document.","solutions":["Check the batch part's type: only parts created with a document payload will return one; skip the document call when not applicable.","Set a batch document when creating the batch (e.g. via runtimeService/process-driven batch creation that supplies the document JSON) if one is required.","Verify the document column in the DB table for that part id is genuinely null (then this is expected data, not a bug).","Handle the 404 response in the REST client and fall back to a default/empty document."],"exampleFix":"// before\nString doc = managementService.getBatchPartDocument(partId); // NPEs/404 when absent\n// after\nBatchPart part = managementService.createBatchPartQuery().batchPartId(partId).singleResult();\nString doc = managementService.getBatchPartDocument(partId);\nif (doc == null) { doc = \"{}\"; /* default document */ }","handlingStrategy":"try-catch","validationCode":"BatchPart part = managementService.createBatchPartQuery().batchPartId(batchPartId).singleResult();\n// no API to pre-check the document; treat null document as expected","typeGuard":null,"tryCatchPattern":"try { doc = client.getBatchPartDocument(partId); }\ncatch (FlowableObjectNotFoundException e) { doc = null; /* part has no document */ }","preventionTips":["Only request documents for batch types known to store one.","Default to an empty JSON document when the fetch 404s.","Verify document storage in the DB when a document is expected.","Read the batch-creation code to confirm a document was supplied."],"tags":["rest-api","flowable","not-found","batch-part","document"],"backgroundTag":"resource-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}