{"record":{"id":"7764dfc6824e7708","repo":"flowable/flowable-engine","slug":"key-is-null-7764df","errorCode":null,"errorMessage":"key is null","messagePattern":"key is null","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/ProcessDefinitionQueryImpl.java","lineNumber":159,"sourceCode":"            throw new ActivitiIllegalArgumentException(\"id is null\");\n        }\n        this.deploymentId = deploymentId;\n        return this;\n    }\n\n    @Override\n    public ProcessDefinitionQueryImpl deploymentIds(Set<String> deploymentIds) {\n        if (deploymentIds == null) {\n            throw new ActivitiIllegalArgumentException(\"ids are null\");\n        }\n        this.deploymentIds = deploymentIds;\n        return this;\n    }\n\n    @Override\n    public ProcessDefinitionQueryImpl processDefinitionKey(String key) {\n        if (key == null) {\n            throw new ActivitiIllegalArgumentException(\"key is null\");\n        }\n        this.key = key;\n        return this;\n    }\n\n    @Override\n    public ProcessDefinitionQueryImpl processDefinitionKeyLike(String keyLike) {\n        if (keyLike == null) {\n            throw new ActivitiIllegalArgumentException(\"keyLike is null\");\n        }\n        this.keyLike = keyLike;\n        return this;\n    }\n\n    @Override\n    public ProcessDefinitionQueryImpl processDefinitionResourceName(String resourceName) {\n        if (resourceName == null) {\n            throw new ActivitiIllegalArgumentException(\"resourceName is null\");","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/ProcessDefinitionQueryImpl.java#L141-L177","documentation":"ProcessDefinitionQueryImpl.processDefinitionKey(String) throws ActivitiIllegalArgumentException 'key is null' when the key argument is null. The process definition key (the bpmn 'process id') is a mandatory non-null filter value, validated eagerly when the query is built. Passing null violates the API contract.","triggerScenarios":"Calling ProcessDefinitionQuery.processDefinitionKey(null), commonly when the key originates from a request parameter, workflow variable, or lookup that returned null.","commonSituations":"Camel/Spring integration passing an unset header as the key; service-layer methods with optional key parameters forwarded straight into the query; typo'd property names leaving the key null in configuration.","solutions":["Pass the actual process definition key (the id attribute of the process in the BPMN XML)","Guard the call: only apply the key filter when the value is non-null","Fail earlier with a domain-specific error if the key is required input","Catch ActivitiIllegalArgumentException and return a meaningful validation message"],"exampleFix":"// before\nquery.processDefinitionKey(variables.get(\"processKey\")); // may be null\n// after\nString key = (String) variables.get(\"processKey\");\nif (key != null) {\n    query.processDefinitionKey(key);\n}","handlingStrategy":"validation","validationCode":"if (key == null || key.isEmpty()) throw new IllegalArgumentException(\"processDefinitionKey is required\");\nquery.processDefinitionKey(key);","typeGuard":"boolean isValidKey(String k) { return k != null && !k.trim().isEmpty(); }","tryCatchPattern":"try {\n    query.processDefinitionKey(key);\n} catch (ActivitiIllegalArgumentException e) {\n    if (e.getMessage().contains(\"key is null\")) {\n        throw new BadRequestException(\"process definition key must not be null\");\n    }\n    throw e;\n}","preventionTips":["Validate workflow variables/headers used as process keys before querying","Use Optional with orElseThrow to make missing keys explicit","Keep key values in typed config objects with non-null invariants","Log the failing filter name when wrapping engine validation errors"],"tags":["java","null-argument","query-builder","activiti","validation"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}