{"record":{"id":"fdd0cbdba86af837","repo":"flowable/flowable-engine","slug":"execution-doesn-t-exist","errorCode":null,"errorMessage":"execution  doesn't exist","messagePattern":"execution  doesn't exist","errorType":"exception","errorClass":"ActivitiObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/GetExecutionVariableCmd.java","lineNumber":55,"sourceCode":"        this.variableName = variableName;\n        this.isLocal = isLocal;\n    }\n\n    @Override\n    public Object execute(CommandContext commandContext) {\n        if (executionId == null) {\n            throw new ActivitiIllegalArgumentException(\"executionId is null\");\n        }\n        if (variableName == null) {\n            throw new ActivitiIllegalArgumentException(\"variableName is null\");\n        }\n\n        ExecutionEntity execution = commandContext\n                .getExecutionEntityManager()\n                .findExecutionById(executionId);\n\n        if (execution == null) {\n            throw new ActivitiObjectNotFoundException(\"execution \" + executionId + \" doesn't exist\", Execution.class);\n        }\n\n        Object value;\n\n        if (isLocal) {\n            value = execution.getVariableLocal(variableName, false);\n        } else {\n            value = execution.getVariable(variableName, false);\n        }\n\n        return value;\n    }\n}\n","sourceCodeStart":37,"sourceCodeEnd":69,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/GetExecutionVariableCmd.java#L37-L69","documentation":"After findExecutionById(executionId) returns null, GetExecutionVariableCmd throws ActivitiObjectNotFoundException(\"execution \" + executionId + \" doesn't exist\", Execution.class). The id was well-formed but no matching execution row exists, typically because the process instance already ended or was deleted.","triggerScenarios":"runtimeService.getVariable(executionId, name) with an id of a finished, canceled, or deleted process instance/execution.","commonSituations":"Reading variables after process completion; stale execution id stored across a long delay; concurrent termination (boundary event, deleteProcessInstance) between obtaining and using the id.","solutions":["Verify the process is still running: runtimeService.createProcessInstanceQuery().processInstanceId(pid).singleResult() != null.","For ended instances, read variables from history: historyService.createHistoricVariableInstanceQuery().executionId(executionId).list().","Handle ActivitiObjectNotFoundException explicitly around the call if racing termination is possible."],"exampleFix":"// before\nObject value = runtimeService.getVariable(executionId, \"status\"); // ObjectNotFound if ended\n// after\nProcessInstance pi = runtimeService.createProcessInstanceQuery()\n    .processInstanceId(processInstanceId).singleResult();\nObject value = (pi != null)\n    ? runtimeService.getVariable(executionId, \"status\")\n    : historyService.createHistoricVariableInstanceQuery()\n        .executionId(executionId).variableName(\"status\").singleResult().getValue();","handlingStrategy":"try-catch","validationCode":"boolean running = runtimeService.createExecutionQuery().executionId(executionId).count() > 0;\nif (!running) {\n    // fall back to historyService for ended instances\n}","typeGuard":null,"tryCatchPattern":"try {\n    return runtimeService.getVariable(executionId, variableName);\n} catch (ActivitiObjectNotFoundException e) {\n    HistoricVariableInstance h = historyService.createHistoricVariableInstanceQuery()\n        .executionId(executionId).variableName(variableName).singleResult();\n    return h != null ? h.getValue() : null;\n}","preventionTips":["Check process-instance liveness before reading runtime variables.","Prefer history queries when reads may happen after process completion.","Treat execution ids as ephemeral; never persist them for long periods."],"tags":["execution","variable","object-not-found","process-ended"],"backgroundTag":"entity-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"}