{"record":{"id":"c0eaa5f52754bafd","repo":"flowable/flowable-engine","slug":"terminatedafter-is-null","errorCode":null,"errorMessage":"terminatedAfter is null","messagePattern":"terminatedAfter 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":584,"sourceCode":"    }\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;\n        }\n        return this;\n    }\n\n    @Override\n    public PlanItemInstanceQuery planItemInstanceFailedBefore(Date failedBefore) {\n        if (failedBefore == null) {\n            throw new FlowableIllegalArgumentException(\"failedBefore is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.failedBefore = failedBefore;\n        } else {\n            this.failedBefore = failedBefore;","sourceCodeStart":566,"sourceCodeEnd":602,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/runtime/PlanItemInstanceQueryImpl.java#L566-L602","documentation":"Flowable throws FlowableIllegalArgumentException when planItemInstanceTerminatedAfter(Date) is called with a null Date. Criteria methods on the plan item instance query validate their argument up front, so a null timestamp fails immediately instead of corrupting the generated query. Leaving the criterion unapplied is done by not calling the method.","triggerScenarios":"Calling createPlanItemInstanceQuery().planItemInstanceTerminatedAfter(null), typically when the after-date comes from an optional parameter or uninitialized field.","commonSituations":"Empty 'terminatedAfter' input in a filter UI; absent JSON field; a null result from Calendar.getTime() on an unset Calendar.","solutions":["Compute a valid non-null Date before invoking the method.","Guard the call with a null check and omit the criterion when absent.","Parse and validate any string input into a Date with explicit failure handling.","Catch FlowableIllegalArgumentException around query building to convert it into a user-facing validation message."],"exampleFix":"// before\nquery.planItemInstanceTerminatedAfter(terminatedAfter); // possibly null\n// after\nif (terminatedAfter != null) {\n    query.planItemInstanceTerminatedAfter(terminatedAfter);\n}","handlingStrategy":"validation","validationCode":"if (terminatedAfter == null) {\n    throw new IllegalArgumentException(\"terminatedAfter must be non-null; omit the filter instead\");\n}\nquery.planItemInstanceTerminatedAfter(terminatedAfter);","typeGuard":"boolean hasTerminatedAfter = (terminatedAfter != null);","tryCatchPattern":"try {\n    query.planItemInstanceTerminatedAfter(terminatedAfter);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().contains(\"terminatedAfter\")) {\n        throw new BadRequestException(\"terminatedAfter date filter must not be null\");\n    }\n    throw e;\n}","preventionTips":["Null-check dates before applying query criteria","Parse string inputs into dates with explicit failure handling","Keep filter application logic in a shared helper that skips nulls","Cover absent-filter paths with unit tests"],"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"}