{"record":{"id":"70f591bfcb5c67c6","repo":"flowable/flowable-engine","slug":"version-must-be-positive-70f591","errorCode":null,"errorMessage":"version must be positive","messagePattern":"version must be positive","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/DecisionQueryImpl.java","lineNumber":232,"sourceCode":"    @Override\n    public DmnDecisionQuery decisionVersionLowerThan(Integer decisionVersion) {\n        checkVersion(decisionVersion);\n        this.versionLt = decisionVersion;\n        return this;\n    }\n\n    @Override\n    public DmnDecisionQuery decisionVersionLowerThanOrEquals(Integer decisionVersion) {\n        checkVersion(decisionVersion);\n        this.versionLte = decisionVersion;\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 DecisionQueryImpl latestVersion() {\n        this.latest = true;\n        return this;\n    }\n\n    @Override\n    public DmnDecisionQuery decisionTenantId(String tenantId) {\n        if (tenantId == null) {\n            throw new FlowableIllegalArgumentException(\"decision tenantId is null\");\n        }\n        this.tenantId = tenantId;\n        return this;\n    }\n","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/DecisionQueryImpl.java#L214-L250","documentation":"DecisionQueryImpl.checkVersion(Integer) throws FlowableIllegalArgumentException(\"version must be positive\") when a version filter method receives an Integer <= 0. DMN decision versions start at 1, so 0 or negative numbers can never match and are treated as invalid input, rejected before the query executes.","triggerScenarios":"Calling decisionVersion(0), decisionVersion(-1), decisionVersionGreaterThan(0), etc. — typically versions initialized to 0 as a sentinel, off-by-one arithmetic, or unvalidated user input.","commonSituations":"Defaults like `int version = 0;` that are never overwritten when config/lookup fails; loop arithmetic or subtraction yielding 0/negative; external systems that report versions starting at 0 while Flowable starts at 1.","solutions":["Pass a version >= 1; add an input check like `if (version < 1) throw ...` before calling the query.","If version is unknown/unset, avoid the version filter entirely or use latestVersion().","Check the numbering convention of the upstream source and add +1 offsets if it starts at 0."],"exampleFix":"// before\nint version = 0; // default\nquery.decisionVersion(version);\n// after\nif (version >= 1) {\n    query.decisionVersion(version);\n} else {\n    query.latestVersion();\n}","handlingStrategy":"validation","validationCode":"if (version != null && version >= 1) {\n    query.decisionVersion(version);\n} else {\n    query.latestVersion();\n}","typeGuard":"boolean isValidVersion(Integer v) { return v != null && v > 0; }","tryCatchPattern":"try {\n    query.decisionVersion(version);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"positive\")) {\n        query.latestVersion();\n    } else { throw e; }\n}","preventionTips":["Remember DMN versions are 1-based","Replace `int version = 0` sentinels with Optional<Integer>","Clamp or reject versions < 1 at input parsing time"],"tags":["java","flowable","dmn","validation","version","query-builder"],"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-14T05:17:10.506Z"}