{"record":{"id":"c40a646aa0ce5c76","repo":"flowable/flowable-engine","slug":"cannot-find-process-definition-with-id-c40a64","errorCode":null,"errorMessage":"Cannot find process definition with id ","messagePattern":"Cannot find process definition with id ","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetPotentialStarterUsersCmd.java","lineNumber":48,"sourceCode":" * @author Tijs Rademakers\n */\npublic class GetPotentialStarterUsersCmd implements Command<List<User>>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n\n    protected String processDefinitionId;\n\n    public GetPotentialStarterUsersCmd(String processDefinitionId) {\n        this.processDefinitionId = processDefinitionId;\n    }\n\n    @SuppressWarnings({ \"unchecked\", \"rawtypes\" })\n    @Override\n    public List<User> execute(CommandContext commandContext) {\n        ProcessDefinitionEntity processDefinition = CommandContextUtil.getProcessDefinitionEntityManager(commandContext).findById(processDefinitionId);\n\n        if (processDefinition == null) {\n            throw new FlowableObjectNotFoundException(\"Cannot find process definition with id \" + processDefinitionId, ProcessDefinition.class);\n        }\n\n        IdentityService identityService = CommandContextUtil.getProcessEngineConfiguration(commandContext).getIdentityService();\n\n        List<String> userIds = new ArrayList<>();\n        List<IdentityLink> identityLinks = (List) processDefinition.getIdentityLinks();\n        for (IdentityLink identityLink : identityLinks) {\n            if (identityLink.getUserId() != null && identityLink.getUserId().length() > 0) {\n\n                if (!userIds.contains(identityLink.getUserId())) {\n                    userIds.add(identityLink.getUserId());\n                }\n            }\n        }\n\n        if (userIds.size() > 0) {\n            return identityService.createUserQuery().userIds(userIds).list();\n","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetPotentialStarterUsersCmd.java#L30-L66","documentation":"GetPotentialStarterUsersCmd.execute mirrors the groups variant: it loads the process definition by id and throws FlowableObjectNotFoundException if findById returns null. Starter users come from the definition's identity links, which cannot be read from a nonexistent definition. This fail-fast prevents a NullPointerException.","triggerScenarios":"Calling the potential-starter-users API (RepositoryService.getIdentityLinksForProcessDefinition family) with a processDefinitionId that does not resolve — deleted definition, wrong environment, key-vs-id confusion, or tenant-specific definition not visible.","commonSituations":"After re-deploying a new version and using a stale id; querying a tenant's definition while running without tenant context; test ids used against a production database; ids read from a config file that drifted from the deployed models.","solutions":["Query the definition first to confirm the id: createProcessDefinitionQuery().processDefinitionId(id).singleResult()","Derive the id from the definition key at runtime instead of hardcoding","Set the correct tenant context or add tenant filters to the definition query","Check deployment history (repositoryService.createDeploymentQuery()) to confirm the definition still exists","Handle FlowableObjectNotFoundException by returning an empty user list and logging the unknown id"],"exampleFix":"// before\nList<User> users = repositoryService.getIdentityLinksForProcessDefinition(staleDefId);\n// after\nProcessDefinition def = repositoryService.createProcessDefinitionQuery()\n    .processDefinitionKey(key).processDefinitionTenantId(tenant).latestVersion().singleResult();\nList<User> users = (def != null)\n    ? repositoryService.getIdentityLinksForProcessDefinition(def.getId())\n    : Collections.emptyList();","handlingStrategy":"validation","validationCode":"ProcessDefinition def = repositoryService.createProcessDefinitionQuery()\n    .processDefinitionKey(key).processDefinitionTenantId(tenant).latestVersion().singleResult();\nif (def == null) throw new IllegalArgumentException(\"No deployed definition for key \" + key);","typeGuard":null,"tryCatchPattern":"try {\n  List<User> users = repositoryService.getIdentityLinksForProcessDefinition(defId);\n} catch (FlowableObjectNotFoundException e) {\n  users = Collections.emptyList();\n}","preventionTips":["Refresh stored definition ids after each redeploy","Include tenant filters in definition lookups","Validate config-file ids against the deployed definitions at startup","Catch FlowableObjectNotFoundException in reporting paths"],"tags":["flowable","process-definition","not-found","start-authorization"],"backgroundTag":"entity-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"}