{"record":{"id":"9d8e7df4059d4c26","repo":"Activiti/Activiti","slug":"set-of-process-definition-keys-is-null","errorCode":null,"errorMessage":"Set of process definition keys is null","messagePattern":"Set of process definition keys is null","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/ProcessInstanceQueryImpl.java","lineNumber":281,"sourceCode":"    }\n\n    public ProcessInstanceQueryImpl processDefinitionKey(String processDefinitionKey) {\n        if (processDefinitionKey == null) {\n            throw new ActivitiIllegalArgumentException(\"Process definition key is null\");\n        }\n\n        if (inOrStatement) {\n            this.currentOrQueryObject.processDefinitionKey = processDefinitionKey;\n        } else {\n            this.processDefinitionKey = processDefinitionKey;\n        }\n        return this;\n    }\n\n    @Override\n    public ProcessInstanceQuery processDefinitionKeys(Set<String> processDefinitionKeys) {\n        if (processDefinitionKeys == null) {\n            throw new ActivitiIllegalArgumentException(\"Set of process definition keys is null\");\n        }\n        if (processDefinitionKeys.isEmpty()) {\n            throw new ActivitiIllegalArgumentException(\"Set of process definition keys is empty\");\n        }\n\n        if (inOrStatement) {\n            this.currentOrQueryObject.processDefinitionKeys = processDefinitionKeys;\n        } else {\n            this.processDefinitionKeys = processDefinitionKeys;\n        }\n        return this;\n    }\n\n    public ProcessInstanceQueryImpl deploymentId(String deploymentId) {\n        if (inOrStatement) {\n            this.currentOrQueryObject.deploymentId = deploymentId;\n        } else {\n            this.deploymentId = deploymentId;","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/Activiti/Activiti/blob/56435b1a97deeafdc09dd40074b056c89fba5a8a/activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/ProcessInstanceQueryImpl.java#L263-L299","documentation":"ProcessInstanceQuery.processDefinitionKeys(Set) throws ActivitiIllegalArgumentException when the keys set is null. Like the other collection filters, the engine requires a real set to build the SQL IN clause.","triggerScenarios":"Calling .processDefinitionKeys(null), e.g. an uninitialized field or a lookup that returned null instead of a set.","commonSituations":"Multi-tenant filters built from nullable tenant metadata; refactored code paths that lost initialization; deserialized DTOs with null collections.","solutions":["Initialize to an empty set and guard with a null/isEmpty check before calling","Only apply the filter when keys were collected","Return an early result or unfiltered query depending on intended semantics"],"exampleFix":"// before\nquery.processDefinitionKeys(processKeys);\n// after\nif (processKeys != null && !processKeys.isEmpty()) {\n    query.processDefinitionKeys(processKeys);\n}","handlingStrategy":"validation","validationCode":"if (keys == null) { throw new IllegalArgumentException(\"processDefinitionKeys must be initialized\"); }\nif (!keys.isEmpty()) { query.processDefinitionKeys(keys); }","typeGuard":"boolean isNonEmptySet(Set<String> s) { return s != null && !s.isEmpty(); }","tryCatchPattern":"try {\n    query.processDefinitionKeys(keys);\n} catch (ActivitiIllegalArgumentException e) {\n    logger.warn(\"Invalid key set: {}\", e.getMessage());\n}","preventionTips":["Default collections to empty sets, never null","Guard set-valued filters with null/isEmpty checks","Validate DTO collections after deserialization"],"tags":["activiti","null-argument","query-api","validation"],"backgroundTag":"null-argument","analyzedSha":"56435b1a97deeafdc09dd40074b056c89fba5a8a","analyzedAt":"2026-09-09T21:00:06.703Z","contentChangedAt":"2026-09-09T21:00:06.703Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}