{"record":{"id":"62026fef41dfd720","repo":"flowable/flowable-engine","slug":"set-of-process-definition-keys-is-empty-62026f","errorCode":null,"errorMessage":"Set of process definition keys is empty","messagePattern":"Set of process definition keys is empty","errorType":"exception","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/ProcessInstanceQueryImpl.java","lineNumber":282,"sourceCode":"        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    @Override\n    public ProcessInstanceQueryImpl deploymentId(String deploymentId) {\n        if (inOrStatement) {\n            this.currentOrQueryObject.deploymentId = deploymentId;\n        } else {\n            this.deploymentId = deploymentId;\n        }\n        return this;","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/ProcessInstanceQueryImpl.java#L264-L300","documentation":"ProcessInstanceQuery.processDefinitionKeys() rejects an empty set of process definition keys. The library requires at least one key because an empty 'IN' clause would produce invalid or meaningless SQL when filtering process instances. Throwing early gives a clear ActivitiIllegalArgumentException instead of a confusing query failure later.","triggerScenarios":"Calling processInstanceQuery().processDefinitionKeys(keys) with a non-null but empty Set<String>, e.g. new HashSet<>() or a set filtered down to zero entries before the query is built.","commonSituations":"Building queries dynamically from user-selected filters where no process definitions were selected; collecting keys from configuration or a database lookup that returned nothing; generics-era refactors where code previously passed null (handled separately) and now passes an empty collection.","solutions":["Guard the caller: only call processDefinitionKeys when the set is non-empty; otherwise skip adding that filter entirely.","If an empty set means 'no filter', omit the call rather than passing the empty set.","If an empty set should mean 'match nothing', use processDefinitionKeys with a sentinel key or handle the no-result case before querying.","Catch ActivitiIllegalArgumentException around query construction to surface a friendly validation message to the user."],"exampleFix":"// before\nquery.processDefinitionKeys(keys); // keys may be empty\n\n// after\nif (keys != null && !keys.isEmpty()) {\n    query.processDefinitionKeys(keys);\n}","handlingStrategy":"validation","validationCode":"if (keys == null || keys.isEmpty()) {\n    throw new IllegalArgumentException(\"processDefinitionKeys must contain at least one key\");\n}\nquery.processDefinitionKeys(keys);","typeGuard":"boolean isValidKeySet(Set<String> keys) {\n    return keys != null && !keys.isEmpty();\n}","tryCatchPattern":"try {\n    query.processDefinitionKeys(keys);\n} catch (org.activiti.engine.ActivitiIllegalArgumentException e) {\n    // handle empty/null key set, e.g. skip filter or return 400\n}","preventionTips":["Treat an empty set as 'no filter' and skip the call.","Validate collections before passing them into query builders.","Add unit tests for empty-collection inputs to query construction code."],"tags":["query","validation","argument-validation","activiti"],"backgroundTag":"empty-required-field","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"}