flowable/flowable-engine · error · FlowableException

Can only delete a child entity for a plan item with…

Error message

Can only delete a child entity for a plan item with reference type ${referenceType} for ${delegatePlanItemInstance}

What it means

deleteChildEntity removes the child entity (child case instance) associated with a case task plan item and is only valid when the plan item's referenceType is PLAN_ITEM_CHILD_CASE. For any other reference type the method cannot know which child to delete and throws this error.

Solutions

  1. Only invoke deleteChildEntity for case task plan items whose referenceType is PLAN_ITEM_CHILD_CASE and referenceId points at a live child case.
  2. Verify the plan item configuration is a real case task with a valid case reference.
  3. If terminating without a child, use the normal plan item termination path instead of child deletion.
  4. Check for corrupted reference_type data in the ACT_CMMN_RU_PLAN_ITEM_INST table.

Example fix

// before
new CaseTaskActivityBehavior().deleteChildEntity(commandContext, pii); // any plan item
// after
if (ReferenceTypes.PLAN_ITEM_CHILD_CASE.equals(pii.getReferenceType())) {
    new CaseTaskActivityBehavior().deleteChildEntity(commandContext, pii);
}
Defensive patterns

Strategy: validation

Validate before calling

if (!ReferenceTypes.PLAN_ITEM_CHILD_CASE.equals(delegatePlanItemInstance.getReferenceType())) {
    // use normal termination path instead of deleteChildEntity
}

Try / catch

try {
    behavior.deleteChildEntity(commandContext, delegatePlanItemInstance);
} catch (FlowableException e) {
    if (e.getMessage().startsWith("Can only delete a child entity")) {
        // fall back to planItem termination
    }
}

Prevention

When it happens

Trigger: Calling CaseTaskActivityBehavior.deleteChildEntity (via case task termination/exit handling) on a delegate plan item instance whose referenceType is not PLAN_ITEM_CHILD_CASE.

Common situations: Terminating a case task that never started a child case or was reused/misconfigured; custom code invoking deleteChildEntity directly; instance data migrated from another task type.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/CaseTaskActivityBehavior.java:248

            if (caseInstance != null && !caseInstance.isDeleted()) {
                CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
                cmmnEngineConfiguration.getCmmnHistoryManager().recordCaseInstanceEnd(
                        caseInstance, CaseInstanceState.TERMINATED, cmmnEngineConfiguration.getClock().getCurrentTime());
                caseInstanceEntityManager.delete(caseInstance.getId(), cascade, null);
            }

            // This is not the regular termination through the agenda, but the historic plan item state still needs to be correct.
            // The child case instance needs to be deleted synchronously (not deferred via the agenda) to preserve entity link cleanup ordering.
            PlanItemInstanceEntity planItemInstanceEntity = (PlanItemInstanceEntity) delegatePlanItemInstance;
            if (!PlanItemInstanceState.TERMINATED.equals(planItemInstanceEntity.getState())) {
                planItemInstanceEntity.setState(PlanItemInstanceState.TERMINATED);
                planItemInstanceEntity.setEndedTime(CommandContextUtil.getCmmnEngineConfiguration(commandContext).getClock().getCurrentTime());
                planItemInstanceEntity.setTerminatedTime(planItemInstanceEntity.getEndedTime());
                CommandContextUtil.getCmmnHistoryManager(commandContext).recordPlanItemInstanceTerminated(planItemInstanceEntity);
            }

        } else {
            throw new FlowableException("Can only delete a child entity for a plan item with reference type " + ReferenceTypes.PLAN_ITEM_CHILD_CASE + " for " + delegatePlanItemInstance);
        }
    }

    protected void handleOutParameters(CommandContext commandContext, PlanItemInstanceEntity planItemInstance) {
        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
        handleOutParameters(planItemInstance, cmmnEngineConfiguration);
    }

    protected void handleOutParameters(DelegatePlanItemInstance planItemInstance, CmmnEngineConfiguration cmmnEngineConfiguration) {
        if (outParameters == null) {
            return;
        }

        CaseInstanceEntityManager caseInstanceEntityManager = cmmnEngineConfiguration.getCaseInstanceEntityManager();
        CaseInstanceEntity referenceCase = caseInstanceEntityManager.findById(planItemInstance.getReferenceId());

        IOParameterUtil.processOutParameters(outParameters, referenceCase, planItemInstance, cmmnEngineConfiguration.getExpressionManager());
    }

View on GitHub (pinned to d6d39ce1c6)