{"record":{"id":"88fed6def97994ee","repo":"flowable/flowable-engine","slug":"could-not-find-a-variable-with-name-variablenam","errorCode":null,"errorMessage":"Could not find a variable with name '${variableName}'.","messagePattern":"Could not find a variable with name '(.+?)'\\.","errorType":"http","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/caze/CaseInstanceVariableResource.java","lineNumber":185,"sourceCode":"            setSimpleVariable(restVariable, caseInstance.getId(), false, true, RestVariable.RestVariableScope.GLOBAL, CmmnRestResponseFactory.VARIABLE_CASE, createVariableInterceptor(caseInstance));\n        }\n    }\n\n    @ApiOperation(value = \"Delete a variable\", tags = { \"Case Instance Variables\" }, nickname = \"deleteCaseInstanceVariable\", code = 204)\n    @ApiResponses(value = {\n            @ApiResponse(code = 204, message = \"Indicates the variable was found and has been deleted. Response-body is intentionally empty.\"),\n            @ApiResponse(code = 404, message = \"Indicates the requested variable was not found.\")\n    })\n    @DeleteMapping(value = \"/cmmn-runtime/case-instances/{caseInstanceId}/variables/{variableName}\")\n    @ResponseStatus(HttpStatus.NO_CONTENT)\n    public void deleteVariable(@ApiParam(name = \"caseInstanceId\") @PathVariable(\"caseInstanceId\") String caseInstanceId, @ApiParam(name = \"variableName\") @PathVariable(\"variableName\") String variableName,\n            @RequestParam(value = \"scope\", required = false) String scope) {\n\n        CaseInstance caseInstance = getCaseInstanceFromRequestWithoutAccessCheck(caseInstanceId);\n        \n        boolean hasVariable = runtimeService.hasVariable(caseInstance.getId(), variableName);\n        if (!hasVariable) {\n            throw new FlowableObjectNotFoundException(\"Could not find a variable with name '\" + variableName + \"'.\");\n        }\n        \n        if (restApiInterceptor != null) {\n            restApiInterceptor.deleteCaseInstanceVariables(caseInstance, Collections.singleton(variableName));\n        }\n\n        runtimeService.removeVariable(caseInstance.getId(), variableName);\n    }\n}\n","sourceCodeStart":167,"sourceCodeEnd":195,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/caze/CaseInstanceVariableResource.java#L167-L195","documentation":"Thrown by deleteVariable when runtimeService.hasVariable reports that the case instance has no variable with the requested name. This is a FlowableObjectNotFoundException (HTTP 404) raised before the deletion, so the variable set is unchanged. Check the case instance id and scope if you believe the variable exists.","triggerScenarios":"DELETE /cmmn-runtime/case-instances/{caseInstanceId}/variables/{variableName} where hasVariable(caseInstanceId, variableName) returns false — variable never set, already deleted, name misspelled, or caseInstanceId wrong.","commonSituations":"Deleting a variable twice (second call 404s); case-sensitivity mismatch in variable names; variable belongs to a task/process scope rather than the case scope; stale client cache after the case instance moved on or completed.","solutions":["Verify the variable exists first via GET /cmmn-runtime/case-instances/{id}/variables and use the exact returned name.","Confirm the caseInstanceId is correct and the case instance is still running.","Check whether the variable is a task-local variable and use the task variable endpoint instead.","Make delete calls idempotent in your client: ignore 404 FlowableObjectNotFoundException when the desired end state is 'variable absent'."],"exampleFix":"// before\ndeleteVariable(caseInstanceId, \"appoved\") // 404\n\n// after\n// GET .../variables -> [\"approved\", ...]\ndeleteVariable(caseInstanceId, \"approved\")","handlingStrategy":"try-catch","validationCode":"// Optional pre-check\nconst vars = await getCaseVariables(caseInstanceId);\nif (!vars.some(v => v.name === variableName)) {\n  return; // nothing to delete\n}","typeGuard":null,"tryCatchPattern":"try {\n  await deleteCaseVariable(caseInstanceId, variableName);\n} catch (e) {\n  if (e.status === 404) {\n    // variable already absent — treat as success\n    return;\n  }\n  throw e;\n}","preventionTips":["List the case instance's variables first and use exact returned names.","Treat deletion 404s as idempotent success when the goal is absence.","Confirm caseInstanceId and variable scope (case vs task) before deleting."],"tags":["rest-api","not-found","variable","case-instance","http-404"],"backgroundTag":"resource-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}