{"record":{"id":"d8a6e63965d6fdb3","repo":"flowable/flowable-engine","slug":"version-must-be-positive-d8a6e6","errorCode":null,"errorMessage":"version must be positive","messagePattern":"version must be positive","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/ProcessDefinitionQueryImpl.java","lineNumber":256,"sourceCode":"    @Override\n    public ProcessDefinitionQuery processDefinitionVersionLowerThan(Integer processDefinitionVersion) {\n        checkVersion(processDefinitionVersion);\n        this.versionLt = processDefinitionVersion;\n        return this;\n    }\n\n    @Override\n    public ProcessDefinitionQuery processDefinitionVersionLowerThanOrEquals(Integer processDefinitionVersion) {\n        checkVersion(processDefinitionVersion);\n        this.versionLte = processDefinitionVersion;\n        return this;\n    }\n\n    protected void checkVersion(Integer version) {\n        if (version == null) {\n            throw new FlowableIllegalArgumentException(\"version is null\");\n        } else if (version <= 0) {\n            throw new FlowableIllegalArgumentException(\"version must be positive\");\n        }\n    }\n\n    @Override\n    public ProcessDefinitionQueryImpl latestVersion() {\n        this.latest = true;\n        return this;\n    }\n\n    @Override\n    public ProcessDefinitionQuery active() {\n        this.suspensionState = SuspensionState.ACTIVE;\n        return this;\n    }\n\n    @Override\n    public ProcessDefinitionQuery suspended() {\n        this.suspensionState = SuspensionState.SUSPENDED;","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/ProcessDefinitionQueryImpl.java#L238-L274","documentation":"ProcessDefinitionQueryImpl.checkVersion validates the version passed to the processDefinitionVersion* filter methods. The Flowable engine throws FlowableIllegalArgumentException when the version is null or <= 0, because process definition versions are 1-based positive integers; a non-positive value would never match any deployed definition.","triggerScenarios":"Calling processDefinitionVersion(0), processDefinitionVersion(-1), processDefinitionVersion(null), or the GreaterThan/GreaterThanOrEquals/LowerThan/LowerThanOrEquals variants with a null or non-positive Integer.","commonSituations":"Computing a version from config or a database value that defaults to 0/null before a definition was ever deployed; off-by-one errors (treating versions as 0-based); passing an unboxed null from a map lookup keyed by a typo'd property name.","solutions":["Pass a version >= 1 (versions are 1-based; the first deployment is version 1).","If you don't know the version, drop the version filter or use latestVersion() instead.","Null-check / range-check the value at the call site before building the query."],"exampleFix":"// before\nint v = config.getInt(\"def.version\", 0);\nProcessDefinitionQuery q = repositoryService.createProcessDefinitionQuery().processDefinitionVersion(v);\n\n// after\nint v = config.getInt(\"def.version\", 1);\nif (v < 1) { v = 1; }\nProcessDefinitionQuery q = repositoryService.createProcessDefinitionQuery().processDefinitionVersion(v);","handlingStrategy":"validation","validationCode":"if (version == null || version < 1) { throw new IllegalArgumentException(\"version must be >= 1, got: \" + version); }","typeGuard":null,"tryCatchPattern":"try { query.processDefinitionVersion(version); } catch (FlowableIllegalArgumentException e) { log.warn(\"Invalid version filter: {}\", e.getMessage()); throw new BadRequestException(e.getMessage()); }","preventionTips":["Remember Flowable process definition versions are 1-based (first deployment = 1).","Default missing version config to latestVersion() rather than 0.","Validate numeric inputs at the API boundary before building engine queries."],"tags":["java","flowable","query-builder","argument-validation"],"backgroundTag":"value-out-of-range","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}