{"record":{"id":"8a96166960137e1c","repo":"flowable/flowable-engine","slug":"process-definition-version-is-null-8a9616","errorCode":null,"errorMessage":"Process definition version is null","messagePattern":"Process definition version is null","errorType":"exception","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/ProcessInstanceQueryImpl.java","lineNumber":220,"sourceCode":"\n    @Override\n    public ProcessInstanceQuery processDefinitionName(String processDefinitionName) {\n        if (processDefinitionName == null) {\n            throw new ActivitiIllegalArgumentException(\"Process definition name is null\");\n        }\n\n        if (inOrStatement) {\n            this.currentOrQueryObject.processDefinitionName = processDefinitionName;\n        } else {\n            this.processDefinitionName = processDefinitionName;\n        }\n        return this;\n    }\n\n    @Override\n    public ProcessInstanceQuery processDefinitionVersion(Integer processDefinitionVersion) {\n        if (processDefinitionVersion == null) {\n            throw new ActivitiIllegalArgumentException(\"Process definition version is null\");\n        }\n\n        if (inOrStatement) {\n            this.currentOrQueryObject.processDefinitionVersion = processDefinitionVersion;\n        } else {\n            this.processDefinitionVersion = processDefinitionVersion;\n        }\n        return this;\n    }\n\n    @Override\n    public ProcessInstanceQueryImpl processDefinitionId(String processDefinitionId) {\n        if (processDefinitionId == null) {\n            throw new ActivitiIllegalArgumentException(\"Process definition id is null\");\n        }\n\n        if (inOrStatement) {\n            this.currentOrQueryObject.processDefinitionId = processDefinitionId;","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/ProcessInstanceQueryImpl.java#L202-L238","documentation":"ProcessInstanceQueryImpl.processDefinitionVersion(Integer) throws ActivitiIllegalArgumentException when the processDefinitionVersion argument is null. Since the parameter is the boxed Integer, a null unboxing scenario or unvalidated value is easy to hit; the API requires a concrete version number and rejects null at query build time. Use processDefinitionVersionGtThan/LessThan variants or omit the call for no filtering.","triggerScenarios":"Calling .processDefinitionVersion(null) — commonly when the version is parsed from a string parameter (result may be null), or an Integer field on a filter DTO was never set.","commonSituations":"Integer.valueOf(requestParam) returning null on blank input; filter objects built from JSON where version was absent; copy-pasted code passing the wrong variable.","solutions":["Ensure the version is a concrete non-null Integer before calling (parse defensively with a default).","Skip the version filter when no version is specified.","Add validation on the parsed value (non-null, positive) before query construction.","Catch ActivitiIllegalArgumentException around query building for a clean validation error."],"exampleFix":"// before\nInteger version = parseVersion(request.getParameter(\"version\"));\nquery.processDefinitionVersion(version);\n// after\nInteger version = parseVersion(request.getParameter(\"version\"));\nif (version != null) {\n    query = query.processDefinitionVersion(version);\n}","handlingStrategy":"validation","validationCode":"Integer version = raw == null || raw.isBlank() ? null : Integer.valueOf(raw);\nif (version != null) {\n    query = query.processDefinitionVersion(version);\n}","typeGuard":"boolean isValidVersion(Integer v) { return v != null && v > 0; }","tryCatchPattern":"try {\n    result = query.processDefinitionVersion(version).list();\n} catch (ActivitiIllegalArgumentException e) {\n    if (e.getMessage().contains(\"Process definition version is null\")) {\n        throw new BadRequestException(\"version must be a valid integer\");\n    }\n    throw e;\n}","preventionTips":["Parse version strings defensively; blank input should mean 'no filter', not null passed through.","Validate parsed integers are positive before filtering.","Keep boxed Integer null-checks explicit; never rely on unboxing.","Centralize parameter parsing so null handling is consistent across endpoints."],"tags":["java","activiti","flowable","null-argument","query-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"}