{"record":{"id":"d3a78232867717bb","repo":"flowable/flowable-engine","slug":"historyjobid-is-null","errorCode":null,"errorMessage":"historyJobId is null","messagePattern":"historyJobId is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/cmd/ExecuteHistoryJobCmd.java","lineNumber":47,"sourceCode":" * @author Joram Barrez\n */\npublic class ExecuteHistoryJobCmd implements Command<Void> {\n\n    private static final Logger LOGGER = LoggerFactory.getLogger(ExecuteHistoryJobCmd.class);\n\n    protected JobServiceConfiguration jobServiceConfiguration;\n    \n    protected String historyJobId;\n\n    public ExecuteHistoryJobCmd(String historyJobId, JobServiceConfiguration jobServiceConfiguration) {\n        this.historyJobId = historyJobId;\n        this.jobServiceConfiguration = jobServiceConfiguration;\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        if (historyJobId == null) {\n            throw new FlowableIllegalArgumentException(\"historyJobId is null\");\n        }\n\n        HistoryJobEntity historyJobEntity = jobServiceConfiguration.getHistoryJobEntityManager().findById(historyJobId);\n        if (historyJobEntity == null) {\n            throw new JobNotFoundException(historyJobId);\n        }\n\n        if (LOGGER.isDebugEnabled()) {\n            LOGGER.debug(\"Executing historyJob {}\", historyJobEntity.getId());\n        }\n\n        try {\n            jobServiceConfiguration.getJobManager().execute(historyJobEntity);\n        } catch (Throwable exception) {\n            // Finally, Throw the exception to indicate the failure\n            throw new FlowableException(historyJobEntity + \" failed\", exception);\n        }\n","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/cmd/ExecuteHistoryJobCmd.java#L29-L65","documentation":"ExecuteHistoryJobCmd throws FlowableIllegalArgumentException when historyJobId is null, then looks up the history job and throws JobNotFoundException if absent. History jobs handle async history persistence, and execution is impossible without a valid id.","triggerScenarios":"Executing new ExecuteHistoryJobCmd(null, cfg); history job handlers invoked with a null id after a fetch produced nothing; JobServiceConfiguration.getExecuteHistoryJobCmd supplied a null id.","commonSituations":"Custom async history handlers where the job id was lost during serialization into the history job queue; tests calling the command directly; misconfigured history job handler factories.","solutions":["Verify the history job id is populated before executing the command.","Check that the history job producer (async history) writes a non-null id into the queued message.","In custom history handlers, guard against null ids and skip/log instead of executing.","Confirm the entity manager can find the id in ACT_RU_HISTORY_JOB before executing."],"exampleFix":"// before\ncommandExecutor.execute(new ExecuteHistoryJobCmd(historyJobId, cfg)); // null id\n// after\nif (historyJobId == null) {\n    LOGGER.warn(\"Skipping history job execution: null id\");\n    return;\n}\ncommandExecutor.execute(new ExecuteHistoryJobCmd(historyJobId, cfg));","handlingStrategy":"validation","validationCode":"if (historyJobId == null) { LOGGER.warn(\"Skip: null history job id\"); return; }","typeGuard":null,"tryCatchPattern":"try { commandExecutor.execute(new ExecuteHistoryJobCmd(historyJobId, cfg)); } catch (FlowableIllegalArgumentException | JobNotFoundException e) { LOGGER.warn(\"History job not executable: {}\", e.getMessage()); }","preventionTips":["Ensure async history producers serialize a non-null job id.","Guard custom history handlers against null ids and skip with a warning.","Test history job round-trips after Flowable upgrades."],"tags":["flowable","job-service","null-argument","history-job"],"backgroundTag":"null-argument","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"}