{"record":{"id":"01005a099d88f485","repo":"flowable/flowable-engine","slug":"key-is-null-01005a","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/ModelQueryImpl.java","lineNumber":112,"sourceCode":"            throw new ActivitiIllegalArgumentException(\"name is null\");\n        }\n        this.name = name;\n        return this;\n    }\n\n    @Override\n    public ModelQueryImpl modelNameLike(String nameLike) {\n        if (nameLike == null) {\n            throw new ActivitiIllegalArgumentException(\"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 ActivitiIllegalArgumentException(\"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 ActivitiIllegalArgumentException(\"version is null\");\n        } else if (version <= 0) {\n            throw new ActivitiIllegalArgumentException(\"version must be positive\");\n        }\n        this.version = version;\n        return this;\n    }\n\n    @Override\n    public ModelQuery latestVersion() {","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/ModelQueryImpl.java#L94-L130","documentation":"Fluent-setter validation in flowable5 ModelQueryImpl.modelKey: a null model key filter was passed and rejected; null is reserved for 'filter unset'.","triggerScenarios":"repositoryService.createModelQuery().modelKey(key) with a null key, e.g. a path/model-lookup value that wasn't resolved.","commonSituations":"Model key not found in an upstream lookup returning null; REST route parameter absent; field not set when building the query programmatically.","solutions":["Ensure the key is resolved to a concrete value before querying; fail earlier with a clearer message if it cannot be","Guard the call with a null/empty check and skip the filter if absent","Verify upstream variable names so the key isn't silently null"],"exampleFix":"// before\nquery.modelKey(params.get(\"key\"));\n// after\nString key = params.get(\"key\");\nif (key != null) { query.modelKey(key); }","handlingStrategy":"validation","validationCode":"if (key != null && !key.isEmpty()) { query.modelKey(key); }","typeGuard":"boolean hasText(String s) { return s != null && !s.trim().isEmpty(); }","tryCatchPattern":"try {\n    query.modelKey(key);\n} catch (ActivitiIllegalArgumentException e) {\n    // handle missing key: return empty result or clear error to caller\n}","preventionTips":["Resolve model keys upstream and fail with a domain-specific error if absent","Never pass Map.get results directly into filter methods","Make key a required, validated path/body parameter"],"tags":["java","flowable","model-query","null-check","query-filter"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T16:30:33.424Z"}