{"record":{"id":"86b7b5feb6dfb047","repo":"flowable/flowable-engine","slug":"provided-activity-id-is-null-86b7b5","errorCode":null,"errorMessage":"Provided activity id is null","messagePattern":"Provided activity id is null","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/EventSubscriptionQueryImpl.java","lineNumber":81,"sourceCode":"    public EventSubscriptionQueryImpl executionId(String executionId) {\r\n        if (executionId == null) {\r\n            throw new ActivitiIllegalArgumentException(\"Provided execution id is null\");\r\n        }\r\n        this.executionId = executionId;\r\n        return this;\r\n    }\r\n\r\n    public EventSubscriptionQueryImpl processInstanceId(String processInstanceId) {\r\n        if (processInstanceId == null) {\r\n            throw new ActivitiIllegalArgumentException(\"Provided process instance id is null\");\r\n        }\r\n        this.processInstanceId = processInstanceId;\r\n        return this;\r\n    }\r\n\r\n    public EventSubscriptionQueryImpl activityId(String activityId) {\r\n        if (activityId == null) {\r\n            throw new ActivitiIllegalArgumentException(\"Provided activity id is null\");\r\n        }\r\n        this.activityId = activityId;\r\n        return this;\r\n    }\r\n\r\n    public EventSubscriptionQueryImpl eventType(String eventType) {\r\n        if (eventType == null) {\r\n            throw new ActivitiIllegalArgumentException(\"Provided event type is null\");\r\n        }\r\n        this.eventType = eventType;\r\n        return this;\r\n    }\r\n\r\n    public String getTenantId() {\r\n        return tenantId;\r\n    }\r\n\r\n    public EventSubscriptionQueryImpl tenantId(String tenantId) {\r","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/EventSubscriptionQueryImpl.java#L63-L99","documentation":"Thrown by EventSubscriptionQueryImpl.activityId when a null activity id is passed as a query criterion. The setter validates its argument immediately, throwing ActivitiIllegalArgumentException, so null activity filters are rejected at query construction rather than silently producing unfiltered results. This indicates the caller must supply a real activity id or omit the criterion.","triggerScenarios":"Calling createEventSubscriptionQuery().activityId(null), e.g. when the activity id comes from a DelegateExecution/ActivityExecution whose current activity is unavailable, or from an unset configuration value.","commonSituations":"Building queries inside delegates where getCurrentActivityId() returns null (e.g. outside an activity scope); activity id taken from a process variable or config key that was never populated; refactored BPMN where the target activity id was renamed/removed.","solutions":["Null-check the activity id and call activityId only when non-null","Obtain the activity id from the correct source, e.g. execution.getCurrentActivityId() while inside an activity scope","Update BPMN/config so the referenced activity id exists and is populated","Build the query conditionally when activity filtering is optional"],"exampleFix":"// before\nEventSubscriptionQuery q = runtimeService.createEventSubscriptionQuery().activityId(actId);\n// after\nEventSubscriptionQuery q = runtimeService.createEventSubscriptionQuery();\nif (actId != null) {\n    q = q.activityId(actId);\n}","handlingStrategy":"validation","validationCode":"if (activityId == null) { throw new IllegalArgumentException(\"activityId must be non-null before querying\"); }\nquery.activityId(activityId);","typeGuard":"boolean hasActivityId(DelegateExecution e) { return e != null && e.getCurrentActivityId() != null; }","tryCatchPattern":"try {\n    query.activityId(actId);\n} catch (org.activiti.engine.ActivitiIllegalArgumentException e) {\n    // actId was null: check you are inside an activity scope or supply the id explicitly\n}","preventionTips":["Only read currentActivityId while inside an activity-scoped delegate","Keep BPMN activity ids in sync with code references; rename consistently","Null-check config/variable-sourced activity ids before querying","Apply the criterion conditionally when activity filtering is optional"],"tags":["java","activiti","query","null-check"],"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"}