{"record":{"id":"ee03b6406016259f","repo":"flowable/flowable-engine","slug":"historic-variable-instance-varinstanceid-coul","errorCode":null,"errorMessage":"Historic variable instance '${varInstanceId}' couldn't be found.","messagePattern":"Historic variable instance '(.+?)' couldn't be found\\.","errorType":"http","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/variable/VariableInstanceBaseResource.java","lineNumber":107,"sourceCode":"        }\n\n        if (queryRequest.getVariables() != null) {\n            addVariables(query, queryRequest.getVariables());\n        }\n        \n        if (restApiInterceptor != null) {\n            restApiInterceptor.accessVariableInfoWithQuery(query, queryRequest);\n        }\n\n        return paginateList(allRequestParams, queryRequest, query, \"variableName\", allowedSortProperties,\n                restResponseFactory::createVariableInstanceResponseList);\n    }\n    \n    public RestVariable getVariableFromRequest(boolean includeBinary, String varInstanceId) {\n        VariableInstance varObject = runtimeService.createVariableInstanceQuery().id(varInstanceId).singleResult();\n\n        if (varObject == null) {\n            throw new FlowableObjectNotFoundException(\"Historic variable instance '\" + varInstanceId + \"' couldn't be found.\", VariableInstanceEntity.class);\n        } else {\n            if (restApiInterceptor != null) {\n                restApiInterceptor.accessVariableInfoById(varObject);\n            }\n            return restResponseFactory.createRestVariable(varObject.getName(), varObject.getValue(), null, varInstanceId, CmmnRestResponseFactory.VARIABLE_HISTORY_VARINSTANCE, includeBinary);\n        }\n    }\n\n    protected void addVariables(VariableInstanceQuery variableInstanceQuery, List<QueryVariable> variables) {\n        for (QueryVariable variable : variables) {\n            if (variable.getVariableOperation() == null) {\n                throw new FlowableIllegalArgumentException(\"Variable operation is missing for variable: \" + variable.getName());\n            }\n            if (variable.getValue() == null) {\n                throw new FlowableIllegalArgumentException(\"Variable value is missing for variable: \" + variable.getName());\n            }\n\n            boolean nameLess = variable.getName() == null;","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/variable/VariableInstanceBaseResource.java#L89-L125","documentation":"Thrown when querying a CMMN variable instance by id (GET /cmmn-runtime/variable-instances/{varInstanceId}) and the runtimeService.createVariableInstanceQuery() returns no row for that id. Despite the message saying 'Historic', this resource actually queries live runtime variable instances, so a variable that is historical-only or deleted cannot be found.","triggerScenarios":"GET /cmmn-runtime/variable-instances/{id} with an id that does not exist, references an already-deleted variable, or an id from the historic variable instance table rather than the runtime table.","commonSituations":"Caller stores variable-instance ids from an old case instance that has completed; mixing up historic-variable-instance ids with runtime ones; typo or wrong engine/database queried.","solutions":["Confirm the variable instance id via GET /cmmn-runtime/variable-instances?... filters instead of assuming a stored id","If the variable is historical, use the history endpoints (query historic variable instances) rather than runtime","Verify the id was created in the same engine/database the REST app points to","Handle 404 gracefully and refresh the variable list for the owning case/task"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const list = await fetch(`/cmmn-runtime/variable-instances?task-id=${taskId}`).then(r => r.json()); const exists = list.data.some(v => v.id === varInstanceId);","typeGuard":"function isRuntimeVariableInstance(v) { return v != null && typeof v.id === 'string' && typeof v.name === 'string'; }","tryCatchPattern":"try { return await getVariableInstance(varInstanceId); } catch (e) { if (e.status === 404) { return null; } throw e; }","preventionTips":["Do not persist runtime variable-instance ids long-term; re-query by task/case id instead","Distinguish runtime vs historic variable ids","Verify you are querying the same engine/database the id was created in"],"tags":["rest-api","variables","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"}