{"record":{"id":"cc30c99e3eba273a","repo":"flowable/flowable-engine","slug":"provided-scope-definition-key-is-null","errorCode":null,"errorMessage":"Provided scope definition key is null","messagePattern":"Provided scope definition key is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-eventsubscription-service/src/main/java/org/flowable/eventsubscription/service/impl/EventSubscriptionQueryImpl.java","lineNumber":334,"sourceCode":"\n        return this;\n    }\n    \n    @Override\n    public EventSubscriptionQueryImpl withoutScopeDefinitionId() {\n        if (inOrStatement) {\n            this.currentOrQueryObject.withoutScopeDefinitionId = true;\n        } else {\n            this.withoutScopeDefinitionId = true;\n        }\n\n        return this;\n    }\n    \n    @Override\n    public EventSubscriptionQueryImpl scopeDefinitionKey(String scopeDefinitionKey) {\n        if (scopeDefinitionKey == null) {\n            throw new FlowableIllegalArgumentException(\"Provided scope definition key is null\");\n        }\n\n        if (inOrStatement) {\n            this.currentOrQueryObject.scopeDefinitionKey = scopeDefinitionKey;\n        } else {\n            this.scopeDefinitionKey = scopeDefinitionKey;\n        }\n\n        return this;\n    }\n    \n    @Override\n    public EventSubscriptionQueryImpl scopeType(String scopeType) {\n        if (scopeType == null) {\n            throw new FlowableIllegalArgumentException(\"Provided scope type is null\");\n        }\n\n        if (inOrStatement) {","sourceCodeStart":316,"sourceCodeEnd":352,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-eventsubscription-service/src/main/java/org/flowable/eventsubscription/service/impl/EventSubscriptionQueryImpl.java#L316-L352","documentation":"Flowable throws FlowableIllegalArgumentException from EventSubscriptionQueryImpl.scopeDefinitionKey when scopeDefinitionKey() is called with null. The definition key is the model-level identifier (BPMN process id / CMMN case id in the XML) and null is rejected during query building. Pass a non-null key or drop the filter.","triggerScenarios":"Calling .scopeDefinitionKey(null), commonly when the key comes from an unset config field, a model attribute that was never read, or shared code where the key is optional.","commonSituations":"Configuration not loaded so the configured process/case key is null; refactoring where a constant was removed; querying across scope types where the key differs per type.","solutions":["Null-check the key before calling scopeDefinitionKey()","Load the key from the process/case definition repository or model and confirm it is present","Omit the filter when the key is unknown","Use scopeDefinitionId() with a resolved id instead of the key"],"exampleFix":"// before\nquery.scopeDefinitionKey(defKey);\n\n// after\nif (defKey != null) {\n    query.scopeDefinitionKey(defKey);\n}","handlingStrategy":"validation","validationCode":"if (scopeDefinitionKey == null) {\n    throw new IllegalStateException(\"scopeDefinitionKey required\");\n}\nquery.scopeDefinitionKey(scopeDefinitionKey);","typeGuard":"if (id instanceof String && !((String) id).isEmpty()) { /* safe to filter */ }","tryCatchPattern":"try {\n    query.scopeDefinitionKey(defKey).list();\n} catch (FlowableIllegalArgumentException e) {\n    // definition key missing\n}","preventionTips":["Ensure configured process/case keys are loaded before querying","Null-check model-sourced keys","Use scopeDefinitionId() when the id is already known"],"tags":["flowable","null-check","query-builder","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"}