{"record":{"id":"5dd5a607d594926e","repo":"flowable/flowable-engine","slug":"version-is-null-5dd5a6","errorCode":null,"errorMessage":"version is null","messagePattern":"version is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/ModelQueryImpl.java","lineNumber":123,"sourceCode":"            throw new FlowableIllegalArgumentException(\"nameLike is null\");\n        }\n        this.nameLike = nameLike;\n        return this;\n    }\n\n    @Override\n    public ModelQuery modelKey(String key) {\n        if (key == null) {\n            throw new FlowableIllegalArgumentException(\"key is null\");\n        }\n        this.key = key;\n        return this;\n    }\n\n    @Override\n    public ModelQueryImpl modelVersion(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        this.version = version;\n        return this;\n    }\n\n    @Override\n    public ModelQuery latestVersion() {\n        this.latest = true;\n        return this;\n    }\n\n    @Override\n    public ModelQuery deploymentId(String deploymentId) {\n        if (deploymentId == null) {\n            throw new FlowableIllegalArgumentException(\"DeploymentId is null\");\n        }","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/ModelQueryImpl.java#L105-L141","documentation":"ModelQueryImpl.modelVersion filters models by an exact version number. Besides rejecting null with FlowableIllegalArgumentException, it also rejects versions <= 0 with 'version must be positive', since model versions start at 1. This validates that the filter is a meaningful positive integer.","triggerScenarios":"Calling repositoryService.createModelQuery().modelVersion(version) with a null Integer, or with a version parsed as 0/negative from user input or a failed parseInt default.","commonSituations":"UIs selecting a specific model version where the selection defaulted to null; parsing version strings where NumberFormatException is swallowed and a 0 is used; pagination code producing off-by-zero version values.","solutions":["Pass a positive, non-null Integer (versions start at 1); to get the latest use latestVersion() instead of modelVersion","Null-check and range-check the value before calling","Ensure version parsing throws/handles failures instead of defaulting to 0","Validate the incoming request field as a positive integer with a clear client-side message"],"exampleFix":"// before\nModelQuery q = repositoryService.createModelQuery()\n    .modelVersion(parseVersion(request.getVersion())); // may be null or 0\n// after\nInteger version = parseVersion(request.getVersion());\nif (version == null || version <= 0) {\n    throw new BadRequestException(\"version must be a positive integer\");\n}\nModelQuery q = repositoryService.createModelQuery().modelVersion(version);","handlingStrategy":"validation","validationCode":"if (version != null && version > 0) { query = query.modelVersion(version); }","typeGuard":"boolean isValidVersion(Integer v) { return v != null && v > 0; }","tryCatchPattern":"try {\n    List<Model> models = query.modelVersion(version).list();\n} catch (FlowableIllegalArgumentException e) {\n    log.warn(\"Bad version filter: {}\", e.getMessage());\n}","preventionTips":["Check both null and positivity before applying a version filter","Parse version input with explicit error handling; never default failed parses to 0","Use latestVersion() when the intent is the newest version rather than a guessed number"],"tags":["java","flowable","query","null-argument","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"}