{"record":{"id":"5f59a66a777cf5d7","repo":"flowable/flowable-engine","slug":"task-formkey-is-null","errorCode":null,"errorMessage":"Task formKey is null","messagePattern":"Task formKey is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/HistoricTaskInstanceQueryImpl.java","lineNumber":1876,"sourceCode":"            this.withoutCategory = true;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoricTaskInstanceQuery taskWithFormKey() {\n        if (inOrStatement) {\n            currentOrQueryObject.withFormKey = true;\n        } else {\n            this.withFormKey = true;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoricTaskInstanceQuery taskFormKey(String formKey) {\n        if (formKey == null) {\n            throw new FlowableIllegalArgumentException(\"Task formKey is null\");\n        }\n\n        if (inOrStatement) {\n            currentOrQueryObject.formKey = formKey;\n        } else {\n            this.formKey = formKey;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoricTaskInstanceQuery taskCandidateUser(String candidateUser) {\n        if (candidateUser == null) {\n            throw new FlowableIllegalArgumentException(\"Candidate user is null\");\n        }\n\n        if (inOrStatement) {\n            this.currentOrQueryObject.candidateUser = candidateUser;","sourceCodeStart":1858,"sourceCodeEnd":1894,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/HistoricTaskInstanceQueryImpl.java#L1858-L1894","documentation":"taskFormKey(String) requires a non-null formKey; passing null throws FlowableIllegalArgumentException(\"Task formKey is null\"). The library validates eagerly so the generated query always has a usable form-key filter.","triggerScenarios":"Calling taskFormKey(null), commonly when the form key comes from an optional configuration value, a null process variable, or an unset request parameter.","commonSituations":"Search forms where the form-key field is optional; service code forwarding a variable that is not set in the given process definition version.","solutions":["Null-check the form key and skip setting the filter when null","Provide a concrete form key value or resolve it before querying","If any form key is acceptable, use a different filter or none"],"exampleFix":"// before\nquery.taskFormKey(formKey); // may be null\n// after\nif (formKey != null) { query.taskFormKey(formKey); }","handlingStrategy":"validation","validationCode":"if (formKey != null) { query.taskFormKey(formKey); }","typeGuard":"boolean hasFormKey(String formKey) { return formKey != null && !formKey.isBlank(); }","tryCatchPattern":"try {\n    query.taskFormKey(formKey);\n} catch (FlowableIllegalArgumentException e) {\n    // query without form-key restriction\n}","preventionTips":["Null-check optional form keys before applying the filter","Resolve form keys from the form repository before querying history","Wrap Flowable query setters in null-safe helper methods used across the codebase"],"tags":["query","validation","null"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}