Activiti/Activiti · error · ActivitiIllegalArgumentException

user id is null

Error message

user id is null

What it means

ExecutionQueryImpl.startedBy(String userId) filters executions started by a specific user. The userId is mandatory; null triggers ActivitiIllegalArgumentException('user id is null') at query construction. Fail-fast validation avoids queries whose filter silently degrades.

Solutions

  1. Require authentication and resolve a non-null user id before building the query; return 401/400 otherwise.
  2. Skip the startedBy filter when no user filter is intended (e.g. admin views all instances).
  3. Fix security-context propagation so async jobs and background threads carry the user id.
  4. Guard: if (userId != null) query.startedBy(userId);

Example fix

// before
ExecutionQuery q = runtimeService.createExecutionQuery().startedBy(securityContext.getUserId());
// after
String userId = securityContext.getUserId();
if (userId == null) { throw new UnauthorizedException("user id required"); }
ExecutionQuery q = runtimeService.createExecutionQuery().startedBy(userId);
Defensive patterns

Strategy: validation

Validate before calling

if (userId == null || userId.isEmpty()) { throw new SecurityException("userId must be resolved (authenticated user) before startedBy()"); }

Type guard

boolean hasUserId(String userId) { return userId != null && !userId.trim().isEmpty(); }

Try / catch

try { query.startedBy(userId); } catch (ActivitiIllegalArgumentException e) { if (e.getMessage().equals("user id is null")) { throw new UnauthorizedException("Authentication required to filter by starter"); } throw e; }

Prevention

When it happens

Trigger: Calling executionQuery.startedBy(null), typically when the authenticated user id is unavailable (anonymous request, security context not populated) and is passed straight into the query.

Common situations: 'My processes' dashboard endpoints hit without authentication, or code that reads the current user from a SecurityContext/ThreadLocal that is empty in async/scheduled threads.

Related errors


AI-assisted analysis of Activiti/Activiti@56435b1a97 (2026-09-09). Data as JSON: /api/errors/297d5dcb81ea08fe. Report an issue: GitHub.

Appendix: source

Thrown at activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/ExecutionQueryImpl.java:342

            throw new ActivitiIllegalArgumentException("before time is null");
        }
        this.startedBefore = beforeTime;

        return this;
    }

    public ExecutionQuery startedAfter(Date afterTime) {
        if (afterTime == null) {
            throw new ActivitiIllegalArgumentException("after time is null");
        }
        this.startedAfter = afterTime;

        return this;
    }

    public ExecutionQuery startedBy(String userId) {
        if (userId == null) {
            throw new ActivitiIllegalArgumentException("user id is null");
        }
        this.startedBy = userId;

        return this;
    }

    // ordering ////////////////////////////////////////////////////

    public ExecutionQueryImpl orderByProcessInstanceId() {
        this.orderProperty = ExecutionQueryProperty.PROCESS_INSTANCE_ID;
        return this;
    }

    public ExecutionQueryImpl orderByProcessDefinitionId() {
        this.orderProperty = ExecutionQueryProperty.PROCESS_DEFINITION_ID;
        return this;
    }

View on GitHub (pinned to 56435b1a97)