{"record":{"id":"06db2c7601320264","repo":"flowable/flowable-engine","slug":"a-maxinstancecount-on-a-repetition-rule-with-val","errorCode":null,"errorMessage":"A 'maxInstanceCount' on a repetition rule with value '0' is not allowed, either set it to '-1' or 'unlimited' or any other positive value..","messagePattern":"A 'maxInstanceCount' on a repetition rule with value '0' is not allowed, either set it to '-1' or 'unlimited' or any other positive value\\.\\.","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/RepetitionRuleXmlConverter.java","lineNumber":63,"sourceCode":"            repetitionRule.setRepetitionCounterVariableName(xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, \n                    CmmnXmlConstants.ATTRIBUTE_REPETITION_COUNTER_VARIABLE_NAME));\n            \n            \n            String ignoreRepetitionCounterVariableValue = xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_IGNORE_REPETITION_COUNTER_VARIABLE);\n            if (\"true\".equalsIgnoreCase(ignoreRepetitionCounterVariableValue)) {\n                repetitionRule.setIgnoreRepetitionCounterVariable(true);\n            }\n\n            String maxInstanceCountValue = xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_REPETITION_MAX_INSTANCE_COUNT_NAME);\n            if (maxInstanceCountValue == null) {\n                repetitionRule.setMaxInstanceCount(null);\n            } else {\n                if (RepetitionRule.MAX_INSTANCE_COUNT_UNLIMITED_VALUE.equals(maxInstanceCountValue)) {\n                    repetitionRule.setMaxInstanceCount(RepetitionRule.MAX_INSTANCE_COUNT_UNLIMITED);\n                } else {\n                    int maxInstanceCount = Integer.parseInt(maxInstanceCountValue);\n                    if (maxInstanceCount == 0) {\n                        throw new FlowableIllegalArgumentException(\"A 'maxInstanceCount' on a repetition rule with value '0' is not allowed, either set it to '-1' or 'unlimited' or any other positive value..\");\n                    }\n                    repetitionRule.setMaxInstanceCount(maxInstanceCount);\n                }\n            }\n\n            repetitionRule.setCollectionVariableName(xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE,\n                CmmnXmlConstants.ATTRIBUTE_REPETITION_COLLECTION_VARIABLE_NAME));\n\n            repetitionRule.setElementVariableName(xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE,\n                CmmnXmlConstants.ATTRIBUTE_REPETITION_ELEMENT_VARIABLE_NAME));\n\n            repetitionRule.setElementIndexVariableName(xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE,\n                CmmnXmlConstants.ATTRIBUTE_REPETITION_ELEMENT_INDEX_VARIABLE_NAME));\n\n            planItemControl.setRepetitionRule(repetitionRule);\n            \n            return repetitionRule;\n        }","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/RepetitionRuleXmlConverter.java#L45-L81","documentation":"A repetition rule's maxInstanceCount attribute may be '-1' (unlimited), 'unlimited', or any positive integer, but 0 is invalid because a plan item could never be repeated. Flowable rejects it during CMMN XML conversion with this FlowableIllegalArgumentException.","triggerScenarios":"Converting CMMN XML where a <repetitionRule> (or its extension attribute) declares maxInstanceCount=\"0\"; the value parses as an integer but equals 0.","commonSituations":"Modelers setting 'max instances' to 0 thinking it disables repetition; programmatic XML generation defaulting the counter to 0.","solutions":["Change maxInstanceCount to a positive value (e.g. 1, 5) in the CMMN XML/model.","Use 'unlimited' (or -1) if repetition should be unbounded.","Remove the repetitionRule if no repetition was intended."],"exampleFix":"// before\n<flowable:repetitionRule flowable:maxInstanceCount=\"0\" />\n// after\n<flowable:repetitionRule flowable:maxInstanceCount=\"3\" />","handlingStrategy":"validation","validationCode":"public static boolean isValidMaxInstanceCount(String v) {\n    if (\"unlimited\".equals(v)) return true;\n    try { return Integer.parseInt(v) != 0; } catch (NumberFormatException e) { return false; }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In UI/modelers, never emit 0 for max instances; use 1 as minimum or 'unlimited'","Add build-time XML linting that rejects maxInstanceCount=\"0\"","Use named constants (RepetitionRule.MAX_INSTANCE_COUNT_UNLIMITED_VALUE) instead of raw strings"],"tags":["cmmn","validation","repetition-rule"],"backgroundTag":"value-out-of-range","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}