{"record":{"id":"65fbc4d74818cfd1","repo":"flowable/flowable-engine","slug":"tenantid-can-only-be-used-with-either-casedefiniti","errorCode":null,"errorMessage":"TenantId can only be used with either caseDefinitionKey.","messagePattern":"TenantId can only be used with either caseDefinitionKey\\.","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/caze/CaseInstanceCollectionResource.java","lineNumber":344,"sourceCode":"    })\n    @PostMapping(value = \"/cmmn-runtime/case-instances\", produces = \"application/json\")\n    @ResponseStatus(HttpStatus.CREATED)\n    public CaseInstanceResponse createCaseInstance(@RequestBody CaseInstanceCreateRequest request) {\n\n        if (request.getCaseDefinitionId() == null && request.getCaseDefinitionKey() == null) {\n            throw new FlowableIllegalArgumentException(\"Either caseDefinitionId or caseDefinitionKey is required.\");\n        }\n\n        int paramsSet = ((request.getCaseDefinitionId() != null) ? 1 : 0) + ((request.getCaseDefinitionKey() != null) ? 1 : 0);\n\n        if (paramsSet > 1) {\n            throw new FlowableIllegalArgumentException(\"Only one of caseDefinitionId or caseDefinitionKey should be set.\");\n        }\n\n        if (request.isTenantSet()) {\n            // Tenant-id can only be used with either key or message\n            if (request.getCaseDefinitionId() != null) {\n                throw new FlowableIllegalArgumentException(\"TenantId can only be used with either caseDefinitionKey.\");\n            }\n        }\n\n        Map<String, Object> startVariables = null;\n        Map<String, Object> transientVariables = null;\n        Map<String, Object> startFormVariables = null;\n        if (request.getStartFormVariables() != null) {\n            startFormVariables = new HashMap<>();\n            for (RestVariable variable : request.getStartFormVariables()) {\n                if (variable.getName() == null) {\n                    throw new FlowableIllegalArgumentException(\"Variable name is required.\");\n                }\n                startFormVariables.put(variable.getName(), restResponseFactory.getVariableValue(variable));\n            }\n\n        }\n\n        if (request.getVariables() != null) {","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/caze/CaseInstanceCollectionResource.java#L326-L362","documentation":"A tenantId in a case instance start request can only be combined with caseDefinitionKey (so the engine resolves the latest definition of that key within the tenant). If tenantId is set together with caseDefinitionId, createCaseInstance throws FlowableIllegalArgumentException (HTTP 400) because a definition id already pins the definition and tenant ambiguity is not resolvable.","triggerScenarios":"POST /cmmn-runtime/case-instances with request.isTenantSet() == true and caseDefinitionId != null.","commonSituations":"Multi-tenant clients that blanket-add tenantId to every start request, copy-pasted payloads combining all optional fields, framework code that injects tenant context into requests that use definition ids.","solutions":["Drop tenantId from the request and use only caseDefinitionId","Or drop caseDefinitionId and use caseDefinitionKey plus tenantId so the tenant-scoped latest version is started","Adjust client/interceptor code that automatically injects tenantId into all start requests"],"exampleFix":"// before\n{\"caseDefinitionId\":\"myCase:1:4\", \"tenantId\":\"tenantA\"}\n// after\n{\"caseDefinitionKey\":\"myCase\", \"tenantId\":\"tenantA\"}","handlingStrategy":"validation","validationCode":"if (request.isTenantSet() && request.getCaseDefinitionId() != null) {\n    throw new IllegalArgumentException(\"tenantId cannot be combined with caseDefinitionId; use caseDefinitionKey\");\n}","typeGuard":"null","tryCatchPattern":"try {\n    startCase(request);\n} catch (HttpClientErrorException.BadRequest e) {\n    if (e.getResponseBodyAsString().contains(\"TenantId can only be used with either caseDefinitionKey\")) {\n        request.setCaseDefinitionId(null);\n        request.setCaseDefinitionKey(resolveKeyFromId(request));\n    }\n}","preventionTips":["Use caseDefinitionKey + tenantId for multi-tenant starts","Do not blanket-inject tenantId into all start requests","Document that tenantId is only valid with key-based resolution"],"tags":["rest","tenant","validation","cmmn"],"backgroundTag":"conflicting-config-options","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"}