flowable/flowable-engine · error · FlowableObjectNotFoundException

Cannot find case instance with id

Error message

Cannot find case instance with id 

What it means

FlowableObjectNotFoundException thrown by DeleteIdentityLinkForCaseInstanceCmd.execute when no case instance exists with the supplied caseInstanceId. The engine looked up the case instance entity before deleting identity links and found nothing.

Source

Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/DeleteIdentityLinkForCaseInstanceCmd.java:70

            throw new FlowableIllegalArgumentException("caseInstanceId is null");
        }

        if (type == null) {
            throw new FlowableIllegalArgumentException("type is required when deleting a process identity link");
        }

        if (userId == null && groupId == null) {
            throw new FlowableIllegalArgumentException("userId and groupId cannot both be null");
        }
    }

    @Override
    public Void execute(CommandContext commandContext) {
        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
        CaseInstance caseInstance = cmmnEngineConfiguration.getCaseInstanceEntityManager().findById(caseInstanceId);

        if (caseInstance == null) {
            throw new FlowableObjectNotFoundException("Cannot find case instance with id " + caseInstanceId, CaseInstanceEntity.class);
        }

        IdentityLinkUtil.deleteCaseInstanceIdentityLinks(caseInstance, userId, groupId, type, cmmnEngineConfiguration);
        
        return null;
    }

}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Fetch/validate the case instance (caseService.createCaseInstanceQuery().caseInstanceId(id).singleResult()) before deleting the link
  2. Confirm the id is a CMMN case instance id, not a task or process instance id
  3. Handle already-deleted case instances gracefully in the caller (idempotent delete)

Example fix

// before
caseService.deleteCaseInstanceIdentityLink(caseInstanceId, userId, groupId, type);
// after
CaseInstance ci = caseService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).singleResult();
if (ci != null) {
    caseService.deleteCaseInstanceIdentityLink(caseInstanceId, userId, groupId, type);
}
Defensive patterns

Strategy: try-catch

Validate before calling

CaseInstance ci = caseService.createCaseInstanceQuery().caseInstanceId(id).singleResult(); if (ci == null) return;

Type guard

boolean exists = id != null && caseService.createCaseInstanceQuery().caseInstanceId(id).count() > 0;

Try / catch

try { caseService.deleteCaseInstanceIdentityLink(id, u, g, t); } catch (FlowableObjectNotFoundException e) { log.warn("case instance {} already gone", id); }

Prevention

When it happens

Trigger: Calling deleteCaseInstanceIdentityLink with a caseInstanceId that was never created, was already deleted, or is a task/process id mistakenly passed in.

Common situations: Stale ids cached in an external app after case instance deletion; copying the wrong id column (task id vs case instance id) in admin tooling; test data cleaned up between runs; id with wrong case vs casing.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/cbb2947e339cbc4a. Report an issue: GitHub.