{"record":{"id":"c4c5930dfa6e9420","repo":"flowable/flowable-engine","slug":"occurredafter-is-null","errorCode":null,"errorMessage":"occurredAfter is null","messagePattern":"occurredAfter 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":558,"sourceCode":"    }\n\n    @Override\n    public PlanItemInstanceQuery planItemInstanceOccurredBefore(Date occurredBefore) {\n        if (occurredBefore == null) {\n            throw new FlowableIllegalArgumentException(\"occurredBefore is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.occurredBefore = occurredBefore;\n        } else {\n            this.occurredBefore = occurredBefore;\n        }\n        return this;\n    }\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;","sourceCodeStart":540,"sourceCodeEnd":576,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/runtime/PlanItemInstanceQueryImpl.java#L540-L576","documentation":"Flowable throws FlowableIllegalArgumentException when planItemInstanceOccurredAfter(Date) is given a null Date argument. This eager validation prevents building a query with an unusable timestamp criterion. To leave the criterion unset, simply do not invoke the method.","triggerScenarios":"Calling createPlanItemInstanceQuery().planItemInstanceOccurredAfter(null), commonly when the after-date comes from an optional API parameter that was not supplied.","commonSituations":"Missing 'occurredAfter' query parameter in a REST endpoint; JSON payload omitting the field; a date formatter returning null on unparseable input.","solutions":["Resolve a valid non-null Date before calling the method.","Conditionally apply the criterion only when the value is present.","Validate/parse user-supplied date strings before constructing the query.","Catch FlowableIllegalArgumentException during query building and return a client validation error."],"exampleFix":"// before\nquery.planItemInstanceOccurredAfter(toDate(request.getOccurredAfter())); // toDate may return null\n// after\nDate occurredAfter = toDate(request.getOccurredAfter());\nif (occurredAfter != null) {\n    query.planItemInstanceOccurredAfter(occurredAfter);\n}","handlingStrategy":"validation","validationCode":"if (occurredAfter == null) {\n    throw new IllegalArgumentException(\"occurredAfter must be non-null; omit the filter instead\");\n}\nquery.planItemInstanceOccurredAfter(occurredAfter);","typeGuard":"boolean hasOccurredAfter = (occurredAfter != null);","tryCatchPattern":"try {\n    query.planItemInstanceOccurredAfter(occurredAfter);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().contains(\"occurredAfter\")) {\n        throw new BadRequestException(\"occurredAfter date filter must not be null\");\n    }\n    throw e;\n}","preventionTips":["Guard date-filter calls with null checks","Parse dates with explicit error handling, never letting null propagate","Make optional filters explicit with Optional<Date>","Test query-building code with absent-filter cases"],"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"}