{"record":{"id":"e7749ada1d173e2b","repo":"flowable/flowable-engine","slug":"terminatedbefore-is-null","errorCode":null,"errorMessage":"terminatedBefore is null","messagePattern":"terminatedBefore is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/runtime/PlanItemInstanceQueryImpl.java","lineNumber":571,"sourceCode":"    }\n\n    @Override\n    public PlanItemInstanceQuery planItemInstanceOccurredAfter(Date occurredAfter) {\n        if (occurredAfter == null) {\n            throw new FlowableIllegalArgumentException(\"occurredAfter is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.occurredAfter = occurredAfter;\n        } else {\n            this.occurredAfter = occurredAfter;\n        }\n        return this;\n    }\n\n    @Override\n    public PlanItemInstanceQuery planItemInstanceTerminatedBefore(Date terminatedBefore) {\n        if (terminatedBefore == null) {\n            throw new FlowableIllegalArgumentException(\"terminatedBefore is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.terminatedBefore = terminatedBefore;\n        } else {\n            this.terminatedBefore = terminatedBefore;\n        }\n        return this;\n    }\n\n    @Override\n    public PlanItemInstanceQuery planItemInstanceTerminatedAfter(Date terminatedAfter) {\n        if (terminatedAfter == null) {\n            throw new FlowableIllegalArgumentException(\"terminatedAfter is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.terminatedAfter = terminatedAfter;\n        } else {\n            this.terminatedAfter = terminatedAfter;","sourceCodeStart":553,"sourceCodeEnd":589,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/runtime/PlanItemInstanceQueryImpl.java#L553-L589","documentation":"Flowable throws FlowableIllegalArgumentException when planItemInstanceTerminatedBefore(Date) receives a null Date. The query API validates each criterion eagerly so malformed queries surface immediately at build time rather than as SQL errors. A null date is not a valid filter; omit the call instead.","triggerScenarios":"Calling createPlanItemInstanceQuery().planItemInstanceTerminatedBefore(null), e.g. when the terminated-before timestamp is sourced from an unset request field.","commonSituations":"Optional 'terminatedBefore' filter left empty in a dashboard search form; DTO field absent after JSON deserialization; null returned by a date-parsing helper.","solutions":["Pass a concrete Date obtained from validated input.","Skip the method call when no terminatedBefore filter is needed.","Validate and convert date strings with explicit error handling before query building.","Wrap query construction in try-catch for FlowableIllegalArgumentException to fail fast."],"exampleFix":"// before\nquery.planItemInstanceTerminatedBefore(filter.getTerminatedBefore()); // may be null\n// after\nif (filter.getTerminatedBefore() != null) {\n    query.planItemInstanceTerminatedBefore(filter.getTerminatedBefore());\n}","handlingStrategy":"validation","validationCode":"if (terminatedBefore == null) {\n    throw new IllegalArgumentException(\"terminatedBefore must be non-null; omit the filter instead\");\n}\nquery.planItemInstanceTerminatedBefore(terminatedBefore);","typeGuard":"boolean hasTerminatedBefore = (terminatedBefore != null);","tryCatchPattern":"try {\n    query.planItemInstanceTerminatedBefore(terminatedBefore);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().contains(\"terminatedBefore\")) {\n        throw new BadRequestException(\"terminatedBefore date filter must not be null\");\n    }\n    throw e;\n}","preventionTips":["Conditionally apply criteria only for present values","Validate DTO fields before passing them to Flowable queries","Normalize date handling in one utility with null semantics documented","Add boundary tests for missing filter values"],"tags":["java","flowable","query","null-argument"],"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"}