{"record":{"id":"656fe62783894acc","repo":"flowable/flowable-engine","slug":"could-not-find-a-plan-item-instance-with-id-pla","errorCode":null,"errorMessage":"Could not find a plan item instance with id '${planItemInstanceId}'.","messagePattern":"Could not find a plan item instance with id '(.+?)'\\.","errorType":"http","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/history/planitem/HistoricPlanItemInstanceResource.java","lineNumber":45,"sourceCode":"import io.swagger.annotations.Authorization;\n\n/**\n * @author Tijs Rademakers\n * @author Dennis Federico\n */\n@RestController\n@Api(tags = {\"History PlanItem\"}, authorizations = {@Authorization(value = \"basicAuth\")})\npublic class HistoricPlanItemInstanceResource extends HistoricPlanItemInstanceBaseResource {\n\n    @ApiOperation(value = \"Get a historic plan item instance\", tags = {\"History PlanItem\"}, nickname = \"getHistoricPlanItemInstance\")\n    @ApiResponses(value = {\n            @ApiResponse(code = 200, message = \"Indicates that the historic plan item instances could be found.\"),\n            @ApiResponse(code = 404, message = \"Indicates that the historic plan item instances could not be found.\")})\n    @GetMapping(value = \"/cmmn-history/historic-planitem-instances/{planItemInstanceId}\", produces = \"application/json\")\n    public HistoricPlanItemInstanceResponse getPlanItemInstance(@ApiParam(name = \"planItemInstanceId\") @PathVariable String planItemInstanceId) {\n        HistoricPlanItemInstance planItemInstance = historyService.createHistoricPlanItemInstanceQuery().planItemInstanceId(planItemInstanceId).singleResult();\n        if (planItemInstance == null) {\n            throw new FlowableObjectNotFoundException(\"Could not find a plan item instance with id '\" + planItemInstanceId + \"'.\", HistoricPlanItemInstance.class);\n        }\n        \n        if (restApiInterceptor != null) {\n            restApiInterceptor.accessHistoryPlanItemInfoById(planItemInstance);\n        }\n        \n        return restResponseFactory.createHistoricPlanItemInstanceResponse(planItemInstance);\n    }\n\n}\n","sourceCodeStart":27,"sourceCodeEnd":56,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/history/planitem/HistoricPlanItemInstanceResource.java#L27-L56","documentation":"FlowableObjectNotFoundException thrown when no historic plan item instance matches the supplied planItemInstanceId. The GET endpoint on /cmmn-history/historic-planitem-instances/{id} looks up the instance via HistoricPlanItemInstanceQuery and fails when singleResult() is null.","triggerScenarios":"GET /cmmn-history/historic-planitem-instances/{planItemInstanceId} with an id that does not exist, was purged by history cleanup, or belongs to another tenant/engine datasource.","commonSituations":"Casing/typo errors in the id; plan item history not recorded because history level is too low; records removed by the Flowable history cleaner after retention expired; ids copied from a test environment.","solutions":["Validate the planItemInstanceId against the list endpoint /cmmn-history/historic-planitem-instances filtered by caseInstanceId.","Catch FlowableObjectNotFoundException and return 404 to the API consumer.","Check history cleanup job configuration/retention times.","Ensure CMMN history level (e.g. 'full') records plan item instances.","Confirm the request targets the correct Flowable engine/database."],"exampleFix":"// before\nvar item = client.getPlanItem(id);\n// after\ntry {\n    var item = client.getPlanItem(id);\n} catch (FlowableObjectNotFoundException e) {\n    return ResponseEntity.notFound().build();\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    HistoricPlanItemInstanceResponse p = getPlanItem(id);\n} catch (FlowableObjectNotFoundException e) {\n    return ResponseEntity.notFound().build();\n}","preventionTips":["Verify ids against the list endpoint before direct lookup.","Account for history purge jobs deleting old plan item instances.","Use correct caseInstanceId filters when enumerating ids.","Keep client/server environments aligned (no cross-env ids)."],"tags":["flowable","rest","history","not-found"],"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-14T05:17:10.506Z"}