{"record":{"id":"b44e2a98ddf35a6b","repo":"flowable/flowable-engine","slug":"referenceid-is-null","errorCode":null,"errorMessage":"referenceId is null","messagePattern":"referenceId is null","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/HistoricCaseInstanceQueryImpl.java","lineNumber":806,"sourceCode":"            this.parentProcessInstanceId = parentProcessInstanceId;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoricCaseInstanceQuery withoutCaseInstanceCallbackId() {\n        if (inOrStatement) {\n            this.currentOrQueryObject.withoutCallbackId = true;\n        } else {\n            this.withoutCallbackId = true;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoricCaseInstanceQuery caseInstanceReferenceId(String referenceId) {\n        if (referenceId == null) {\n            throw new FlowableIllegalArgumentException(\"referenceId is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.referenceId = referenceId;\n        } else {\n            this.referenceId = referenceId;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoricCaseInstanceQuery caseInstanceReferenceType(String referenceType) {\n        if (referenceType == null) {\n            throw new FlowableIllegalArgumentException(\"referenceType is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.referenceType = referenceType;\n        } else {\n            this.referenceType = referenceType;","sourceCodeStart":788,"sourceCodeEnd":824,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/HistoricCaseInstanceQueryImpl.java#L788-L824","documentation":"HistoricCaseInstanceQueryImpl.caseInstanceReferenceId(String) throws when the referenceId argument is null. Reference id is a free-form correlation field stored on the case instance; as a query filter it must be a concrete non-null string, otherwise the builder raises FlowableIllegalArgumentException right away.","triggerScenarios":"Calling caseInstanceReferenceId(null) — typically the reference id came from an optional request parameter, message correlation payload, or variable lookup that was absent.","commonSituations":"REST endpoints where referenceId is an optional query parameter passed unfiltered into the query builder; copying reference data from a business object where the field was never set; migration scripts with incomplete data.","solutions":["Pass a non-null reference id string.","Conditionally add the reference-id filter only when the value is present.","Sanitize optional request parameters before passing them into the query builder."],"exampleFix":"// before\nquery.caseInstanceReferenceId(request.getReferenceId()); // optional, may be null\n// after\nif (request.getReferenceId() != null) {\n    query.caseInstanceReferenceId(request.getReferenceId());\n}","handlingStrategy":"validation","validationCode":"if (referenceId != null) {\n    query.caseInstanceReferenceId(referenceId);\n}","typeGuard":"boolean isSet(String s) { return s != null && !s.trim().isEmpty(); }","tryCatchPattern":"try {\n    query.caseInstanceReferenceId(refId);\n} catch (FlowableIllegalArgumentException e) {\n    throw new BadRequestException(\"referenceId must not be null\", e);\n}","preventionTips":["Sanitize optional request parameters before passing them to query builders.","Null-check business-object fields that back correlation filters.","Keep query construction in one guarded utility method."],"tags":["null-argument","query","cmmn","validation"],"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"}