{"record":{"id":"6cbcb6f3f36a1ce9","repo":"flowable/flowable-engine","slug":"cannot-find-case-definition-with-id-6cbcb6","errorCode":null,"errorMessage":"Cannot find case definition with id ","messagePattern":"Cannot find case definition with id ","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/ModifyCaseInstanceStartEventSubscriptionCmd.java","lineNumber":53,"sourceCode":"    protected final CaseInstanceStartEventSubscriptionModificationBuilderImpl builder;\n\n    public ModifyCaseInstanceStartEventSubscriptionCmd(CaseInstanceStartEventSubscriptionModificationBuilderImpl builder) {\n        this.builder = builder;\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        CaseDefinition newCaseDefinition;\n        if (builder.hasNewCaseDefinitionId()) {\n            newCaseDefinition = getCaseDefinitionById(builder.getNewCaseDefinitionId(), commandContext);\n        } else {\n            // no explicit case definition provided, so use latest one\n            CaseDefinition caseDefinition = getCaseDefinitionById(builder.getCaseDefinitionId(), commandContext);\n            newCaseDefinition = getLatestCaseDefinitionByKey(caseDefinition.getKey(), caseDefinition.getTenantId(), commandContext);\n        }\n\n        if (newCaseDefinition == null) {\n            throw new FlowableIllegalArgumentException(\"Cannot find case definition with id \" + (builder.hasNewCaseDefinitionId() ?\n                builder.getNewCaseDefinitionId() :\n                builder.getCaseDefinitionId()));\n        }\n\n        Case caze = getCase(newCaseDefinition.getId(), commandContext);\n\n        String eventDefinitionKey = caze.getStartEventType();\n        String startCorrelationConfiguration = getStartCorrelationConfiguration(newCaseDefinition.getId(), commandContext);\n\n        if (eventDefinitionKey != null && Objects.equals(startCorrelationConfiguration, CmmnXmlConstants.START_EVENT_CORRELATION_MANUAL)) {\n            String correlationKey = null;\n\n            if (builder.hasCorrelationParameterValues()) {\n                correlationKey = generateCorrelationConfiguration(eventDefinitionKey, builder.getTenantId(),\n                        builder.getCorrelationParameterValues(), commandContext);\n            }\n\n            getEventSubscriptionService(commandContext).updateEventSubscriptionScopeDefinitionId(builder.getCaseDefinitionId(), newCaseDefinition.getId(),","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/ModifyCaseInstanceStartEventSubscriptionCmd.java#L35-L71","documentation":"ModifyCaseInstanceStartEventSubscriptionCmd.execute() resolves the target case definition when changing a case instance's start event subscription. If the resolved newCaseDefinition is null (neither a new definition id nor the latest definition by key could be found) it throws FlowableIllegalArgumentException 'Cannot find case definition with id <id>'.","triggerScenarios":"Calling CaseInstanceStartEventSubscriptionBuilder.changeSubscription()/start() with newCaseDefinitionId pointing at a non-deployed/deleted case definition, or where getLatestCaseDefinitionByKey returns null because the latest version of the original definition no longer exists.","commonSituations":"Definition id from another engine/database environment (test vs prod); definition deleted via cascading delete before the subscription change; typo in definition id string; migrations that removed the latest version.","solutions":["Verify the case definition id exists: query the CmmnRepositoryService case-definition query for the id before changing the subscription","If relying on 'latest by key', confirm at least one deployed definition with that key still exists","Use CaseDefinitionNotFoundException handling / FlowableIllegalArgumentException catch to surface a user-friendly message"],"exampleFix":"// before\nbuilder.newCaseDefinitionId(\"def-does-not-exist\").changeSubscription();\n// after\nCaseDefinition def = cmmnRepositoryService.createCaseDefinitionQuery().caseDefinitionId(\"correct-def-id\").singleResult();\nbuilder.newCaseDefinitionId(def.getId()).changeSubscription();","handlingStrategy":"validation","validationCode":"CaseDefinition cd = cmmnRepositoryService.createCaseDefinitionQuery().caseDefinitionId(defId).singleResult();\nif (cd == null) throw new IllegalArgumentException(\"Case definition not deployed: \" + defId);","typeGuard":null,"tryCatchPattern":"try { builder.newCaseDefinitionId(defId).changeSubscription(); } catch (FlowableIllegalArgumentException e) { log.error(\"Case definition missing: {}\", e.getMessage()); }","preventionTips":["Resolve ids via repository queries, never hard-code definition ids across environments","Re-check definition existence after deployments/undeployments in automated pipelines","Catch FlowableIllegalArgumentException around subscription changes to give user-friendly errors"],"tags":["flowable","cmmn","case-definition-not-found","start-event-subscription"],"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-14T05:17:10.506Z"}