{"record":{"id":"bb5c89035ea35716","repo":"flowable/flowable-engine","slug":"you-need-to-provide-the-case-instance-id-in-order","errorCode":null,"errorMessage":"You need to provide the case instance id in order to set its name","messagePattern":"You need to provide the case instance id in order to set its name","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetCaseInstanceNameCmd.java","lineNumber":40,"sourceCode":"/**\n * A command to set or change the name of a case instance.\n *\n * @author Micha Kiener\n */\npublic class SetCaseInstanceNameCmd implements Command<Void> {\n\n    protected String caseInstanceId;\n    protected String caseName;\n\n    public SetCaseInstanceNameCmd(String caseInstanceId, String caseName) {\n        this.caseInstanceId = caseInstanceId;\n        this.caseName = caseName;\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        if (caseInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"You need to provide the case instance id in order to set its name\");\n        }\n\n        CaseInstanceEntity caseInstanceEntity = CommandContextUtil.getCaseInstanceEntityManager(commandContext).findById(caseInstanceId);\n        if (caseInstanceEntity == null) {\n            throw new FlowableObjectNotFoundException(\"No case instance found for id \" + caseInstanceId, CaseInstanceEntity.class);\n        }\n        caseInstanceEntity.setName(caseName);\n\n        CommandContextUtil.getCmmnHistoryManager().recordUpdateCaseInstanceName(caseInstanceEntity, caseName);\n\n        return null;\n    }\n\n}\n","sourceCodeStart":22,"sourceCodeEnd":55,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetCaseInstanceNameCmd.java#L22-L55","documentation":"SetCaseInstanceNameCmd.execute validates that a caseInstanceId was supplied; if it is null, FlowableIllegalArgumentException is thrown with the message 'You need to provide the case instance id in order to set its name'. This prevents issuing a name update with no target entity.","triggerScenarios":"Calling CmmnRuntimeService.setCaseInstanceName(null, caseName).","commonSituations":"A variable holding the id was never populated; a caller chain lost the id between service layers; optional request fields left null and passed straight through.","solutions":["Provide a non-null caseInstanceId to setCaseInstanceName","Add an explicit null check in your own code before calling the API","Trace where the id becomes null (unbound parameter, failed lookup upstream) and fix the source"],"exampleFix":"// before\ncmmnRuntimeService.setCaseInstanceName(caseInstanceId, newName); // caseInstanceId may be null\n// after\nObjects.requireNonNull(caseInstanceId, \"caseInstanceId is required\");\ncmmnRuntimeService.setCaseInstanceName(caseInstanceId, newName);","handlingStrategy":"validation","validationCode":"if (caseInstanceId == null) {\n    throw new IllegalArgumentException(\"caseInstanceId is required to set the case name\");\n}","typeGuard":"boolean hasId(String id) { return id != null && !id.isEmpty(); }","tryCatchPattern":"try {\n    cmmnRuntimeService.setCaseInstanceName(caseInstanceId, name);\n} catch (FlowableIllegalArgumentException e) {\n    throw new BadRequestException(e.getMessage(), e);\n}","preventionTips":["Null-check ids at service boundaries before engine calls","Use Objects.requireNonNull for programmer-error nulls","Ensure upstream lookups propagate non-null ids or fail early"],"tags":["flowable","cmmn","validation","null-argument"],"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"}