{"record":{"id":"4c0a1e3cf084110d","repo":"flowable/flowable-engine","slug":"no-history-job-found-with-id","errorCode":null,"errorMessage":"No history job found with id '","messagePattern":"No history job found with id '","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/cmd/DeleteHistoryJobCmd.java","lineNumber":76,"sourceCode":"    protected void sendCancelEvent(HistoryJobEntity jobToDelete) {\n        FlowableEventDispatcher eventDispatcher = jobServiceConfiguration.getEventDispatcher();\n        if (eventDispatcher != null && eventDispatcher.isEnabled()) {\n            eventDispatcher.dispatchEvent(FlowableJobEventBuilder.createEntityEvent(FlowableEngineEventType.JOB_CANCELED, jobToDelete),\n                    jobServiceConfiguration.getEngineName());\n        }\n    }\n\n    protected HistoryJobEntity getJobToDelete(CommandContext commandContext) {\n        if (historyJobId == null) {\n            throw new FlowableIllegalArgumentException(\"jobId is null\");\n        }\n        if (LOGGER.isDebugEnabled()) {\n            LOGGER.debug(\"Deleting job {}\", historyJobId);\n        }\n\n        HistoryJobEntity job = jobServiceConfiguration.getHistoryJobEntityManager().findById(historyJobId);\n        if (job == null) {\n            throw new FlowableObjectNotFoundException(\"No history job found with id '\" + historyJobId + \"'\", Job.class);\n        }\n\n        return job;\n    }\n\n}\n","sourceCodeStart":58,"sourceCodeEnd":83,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/cmd/DeleteHistoryJobCmd.java#L58-L83","documentation":"DeleteHistoryJobCmd fetches the history job with HistoryJobEntityManager.findById and throws FlowableObjectNotFoundException including the requested id when no history job entity exists. The async history job row (ACT_RU_HISTORY_JOB) was not found for that identifier.","triggerScenarios":"Deleting a history job after the async executor already executed and removed it; deleting with an id from a completed/failed history job list that has since been purged; wrong id or wrong engine database.","commonSituations":"History cleanup jobs racing with the async executor; test teardown code deleting history jobs twice; environments where async history was toggled off and old ids no longer resolve; querying with a job id instead of a history job id.","solutions":["Query for the history job (createHistoryJobQuery / historyJobEntityManager) before deleting and handle the not-found case gracefully.","Make repeated cleanup idempotent by catching FlowableObjectNotFoundException and continuing.","Confirm async history is enabled and the job hasn't been consumed by the history executor between listing and deletion.","Verify the id against the ACT_RU_HISTORY_JOB table and the engine configuration (database schema) in use."],"exampleFix":"// before\nmanagementService.executeCommand(new DeleteHistoryJobCmd(historyJobId));\n// after\ntry {\n    managementService.executeCommand(new DeleteHistoryJobCmd(historyJobId));\n} catch (FlowableObjectNotFoundException e) {\n    // already executed/purged; nothing to delete\n}","handlingStrategy":"try-catch","validationCode":"if (managementService.createHistoryJobQuery().jobId(historyJobId).count() == 0) {\n    LOGGER.info(\"History job {} not present; nothing to delete\", historyJobId);\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n    managementService.executeCommand(new DeleteHistoryJobCmd(historyJobId));\n} catch (FlowableObjectNotFoundException e) {\n    LOGGER.info(\"History job {} already executed/purged\", historyJobId);\n}","preventionTips":["Expect the async history executor to consume jobs between listing and deletion.","Write cleanup loops that tolerate vanished ids.","Confirm the id belongs to ACT_RU_HISTORY_JOB."],"tags":["flowable","history-job","not-found"],"backgroundTag":"record-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}