{"record":{"id":"7145681365efd115","repo":"flowable/flowable-engine","slug":"form-model-for-task-task-gettaskdefinitionkey","errorCode":null,"errorMessage":"Form model for task ${task.getTaskDefinitionKey()} cannot be found for form key ${task.getFormKey()}","messagePattern":"Form model for task (.+?) cannot be found for form key (.+?)","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetTaskFormModelCmd.java","lineNumber":118,"sourceCode":"\n        FormInfo formInfo = null;\n        if (ignoreVariables) {\n            FormRepositoryService formRepositoryService = CommandContextUtil.getFormRepositoryService();\n            formInfo = formRepositoryService.getFormModelByKeyAndParentDeploymentId(task.getFormKey(), parentDeploymentId, \n                            task.getTenantId(), cmmnEngineConfiguration.isFallbackToDefaultTenant());\n            \n        } else if (endTime != null) {\n            formInfo = formService.getFormInstanceModelByKeyAndParentDeploymentIdAndScopeId(task.getFormKey(), parentDeploymentId, task.getScopeId(), \n                            task.getScopeType(), variables, task.getTenantId(), cmmnEngineConfiguration.isFallbackToDefaultTenant());\n\n        } else {\n            formInfo = formService.getFormModelWithVariablesByKeyAndParentDeploymentId(task.getFormKey(), parentDeploymentId,\n                            taskId, variables, task.getTenantId(), cmmnEngineConfiguration.isFallbackToDefaultTenant());\n        }\n\n        // If form does not exists, we don't want to leak out this info to just anyone\n        if (formInfo == null) {\n            throw new FlowableObjectNotFoundException(\"Form model for task \" + task.getTaskDefinitionKey() + \" cannot be found for form key \" + task.getFormKey());\n        }\n\n        FormFieldHandler formFieldHandler = cmmnEngineConfiguration.getFormFieldHandler();\n        formFieldHandler.enrichFormFields(formInfo);\n\n        return formInfo;\n    }\n\n}\n","sourceCodeStart":100,"sourceCodeEnd":128,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetTaskFormModelCmd.java#L100-L128","documentation":"GetTaskFormModelCmd throws FlowableObjectNotFoundException when the form repository returns null FormInfo for the task's form key. The message intentionally omits existence details ('we don't want to leak out this info'), covering both missing forms and unauthorized access.","triggerScenarios":"Task's formKey has no deployed matching form (form not deployed, key mismatch, wrong parent deployment id), or the form instance cannot be resolved for the task's scope/tenant.","commonSituations":"Case/task models deployed without accompanying .form resources; formKey changed in the model after deployment; multi-tenant setups where forms deploy under a different tenant than the task; form deleted after deployment.","solutions":["Deploy the .form definition whose key matches the task's formKey in the same deployment as the case model","Verify task.getFormKey() against deployed form keys in the form repository","Check tenant/parentDeploymentId resolution — enable fallbackToDefaultTenant in the engine config if forms are in the default tenant","Redeploy both the case model and forms together to keep keys and deployments in sync"],"exampleFix":"// before\nFormInfo info = cmmnTaskService.getTaskFormModel(taskId); // throws when form key unresolvable\n// after\nFormInfo info = null;\ntry { info = cmmnTaskService.getTaskFormModel(taskId); }\ncatch (FlowableObjectNotFoundException e) {\n    // redeploy missing form for task definition key 'approveTask' with key matching the task's formKey\n}\n","handlingStrategy":"try-catch","validationCode":"FormDefinition f = formRepositoryService.createFormDefinitionQuery()\n    .formKey(task.getFormKey())\n    .tenantId(task.getTenantId())\n    .singleResult();\nif (f == null) {\n    throw new IllegalStateException(\"Form not deployed for key \" + task.getFormKey());\n}","typeGuard":null,"tryCatchPattern":"try {\n    FormInfo info = cmmnTaskService.getTaskFormModel(taskId);\n} catch (FlowableObjectNotFoundException e) {\n    // form missing or unauthorized; log taskDefinitionKey + formKey and redeploy form\n}","preventionTips":["Version case models and forms together in one deployment","Validate formKey references at build time against the form repository","Watch for null FormInfo on multi-tenant setups; configure tenant fallback"],"tags":["cmmn","forms","not-found"],"backgroundTag":"form-definition-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"}