{"record":{"id":"447167050801ea50","repo":"flowable/flowable-engine","slug":"selectcaseinstanceeagerfetchplaniteminstances-need","errorCode":null,"errorMessage":"selectCaseInstanceEagerFetchPlanItemInstances needs either caseInstanceId or planItemInstanceId","messagePattern":"selectCaseInstanceEagerFetchPlanItemInstances needs either caseInstanceId or planItemInstanceId","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/persistence/entity/data/impl/MybatisCaseInstanceDataManagerImpl.java","lineNumber":91,"sourceCode":"    public CaseInstanceEntity findCaseInstanceEntityEagerFetchPlanItemInstances(String caseInstanceId, String planItemInstanceId) {\n\n        // Could have been fetched before\n        EntityCache entityCache = getEntityCache();\n        CaseInstanceEntity cachedCaseInstanceEntity = entityCache.findInCache(getManagedEntityClass(), caseInstanceId);\n        if (cachedCaseInstanceEntity != null) {\n            return cachedCaseInstanceEntity;\n        }\n\n        // Not in cache\n        HashMap<String, Object> params = new HashMap<>(1);\n        if (caseInstanceId != null) {\n            params.put(\"caseInstanceId\", caseInstanceId);\n        } else if (planItemInstanceId != null) {\n            params.put(\"planItemInstanceId\", planItemInstanceId);\n        }\n\n        if (params.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"selectCaseInstanceEagerFetchPlanItemInstances needs either caseInstanceId or planItemInstanceId\");\n        }\n\n        // The case instance will be fetched and will have all plan item instances in the childPlanItemInstances property.\n        // Those children need to be properly moved to the correct parent\n        CaseInstanceEntityImpl caseInstanceEntity = (CaseInstanceEntityImpl) getDbSqlSession().selectOne(\"selectCaseInstanceEagerFetchPlanItemInstances\", params);\n\n        if (caseInstanceEntity != null) {\n            List<PlanItemInstanceEntity> allPlanItemInstances = caseInstanceEntity.getChildPlanItemInstances();\n            ArrayList<PlanItemInstanceEntity> directPlanItemInstances = new ArrayList<>();\n            HashMap<String, PlanItemInstanceEntity> planItemInstanceMap = new HashMap<>(allPlanItemInstances.size());\n\n            // Map all plan item instances to its id\n            for (PlanItemInstanceEntity planItemInstanceEntity : allPlanItemInstances) {\n\n                PlanItemInstanceEntity currentPlanItemInstanceEntity = planItemInstanceEntity;\n\n                // If it's already in the cache, it has precedence on the fetched one\n                PlanItemInstanceEntity planItemInstanceFromCache = entityCache.findInCache(PlanItemInstanceEntityImpl.class, planItemInstanceEntity.getId());","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/persistence/entity/data/impl/MybatisCaseInstanceDataManagerImpl.java#L73-L109","documentation":"Thrown by MybatisCaseInstanceDataManagerImpl.findCaseInstanceEntityEagerFetchPlanItemInstances when neither caseInstanceId nor planItemInstanceId was supplied. The eager-fetch query needs at least one of these parameters to identify which case instance to load with its plan item instances.","triggerScenarios":"Calling findById(null, null) (or equivalent) on the case instance data manager with both parameters null.","commonSituations":"Custom engine extensions that pass through null values from an upper layer; refactored code where one of the two identifiers became null due to an upstream bug.","solutions":["Pass a non-null caseInstanceId or planItemInstanceId to findById","Ensure the calling code actually resolved one of the two identifiers before doing the eager fetch"],"exampleFix":"// before\ncaseInstanceEntityManager.findById(null, null);\n// after\ncaseInstanceEntityManager.findById(caseInstanceId, null);","handlingStrategy":"validation","validationCode":"if (caseInstanceId == null && planItemInstanceId == null) {\n    throw new IllegalArgumentException(\"Either caseInstanceId or planItemInstanceId is required\");\n}","typeGuard":"boolean hasIdentifier = caseInstanceId != null || planItemInstanceId != null;","tryCatchPattern":"try {\n    return dataManager.findCaseInstanceEntityEagerFetchPlanItemInstances(caseInstanceId, planItemInstanceId);\n} catch (FlowableIllegalArgumentException e) {\n    // resolve an identifier from the caller context first\n}","preventionTips":["Resolve at least one identifier before doing eager fetches","Keep upstream code from silently propagating null ids","Unit-test data manager helpers with null-argument cases"],"tags":["cmmn","validation","null-argument"],"backgroundTag":"missing-required-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"}