{"record":{"id":"dbf7129597e90757","repo":"flowable/flowable-engine","slug":"jobid-is-null-dbf712","errorCode":null,"errorMessage":"jobId is null","messagePattern":"jobId is null","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/GetJobExceptionStacktraceCmd.java","lineNumber":40,"sourceCode":"import org.activiti.engine.impl.persistence.entity.JobEntity;\nimport org.flowable.job.api.Job;\n\n/**\n * @author Frederik Heremans\n */\npublic class GetJobExceptionStacktraceCmd implements Command<String>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    private String jobId;\n\n    public GetJobExceptionStacktraceCmd(String jobId) {\n        this.jobId = jobId;\n    }\n\n    @Override\n    public String execute(CommandContext commandContext) {\n        if (jobId == null) {\n            throw new ActivitiIllegalArgumentException(\"jobId is null\");\n        }\n\n        JobEntity job = commandContext\n                .getJobEntityManager()\n                .findJobById(jobId);\n\n        if (job == null) {\n            throw new ActivitiObjectNotFoundException(\"No job found with id \" + jobId, Job.class);\n        }\n\n        return job.getExceptionStacktrace();\n    }\n\n}\n","sourceCodeStart":22,"sourceCodeEnd":55,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/GetJobExceptionStacktraceCmd.java#L22-L55","documentation":"Null-argument guard in flowable5 GetJobExceptionStacktraceCmd.execute: the jobId supplied to fetch a job's exception stacktrace is null, so the command aborts before the job entity lookup.","triggerScenarios":"Calling ManagementService.getJobExceptionStacktrace(null); typically a job id variable that was never assigned, e.g. iterating jobs with a broken lookup or passing an uninitialised field.","commonSituations":"Null returned from a previous query (singleResult() on no match) and passed straight through; unmarshalled API payloads missing the job id; refactoring left the id unset.","solutions":["Ensure a valid job id is passed, obtained via managementService.createJobQuery().list() or timer/job tables","Add a null check before calling getJobExceptionStacktrace","Fix upstream code that produced a null id (e.g. singleResult() on an empty query)"],"exampleFix":"// before\nJob job = managementService.createJobQuery().jobId(badId).singleResult();\nString st = managementService.getJobExceptionStacktrace(job == null ? null : job.getId());\n// after\nJob job = managementService.createJobQuery().jobId(badId).singleResult();\nString st = job != null ? managementService.getJobExceptionStacktrace(job.getId()) : null;","handlingStrategy":"validation","validationCode":"if (jobId == null) {\n    throw new IllegalArgumentException(\"jobId must be provided\");\n}","typeGuard":"boolean hasJobId(String jobId) { return jobId != null; }","tryCatchPattern":"try {\n    managementService.getJobExceptionStacktrace(jobId);\n} catch (ActivitiIllegalArgumentException e) {\n    // null job id: fix caller\n}","preventionTips":["Never pass singleResult() output ids without a null check","Assert job ids are populated in integration tests","Keep id-typed variables explicit to catch nulls at compile/review time"],"tags":["flowable","activiti","null-argument","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-18T11:17:12.947Z"}