flowable/flowable-engine · error · FlowableIllegalArgumentException
A 'maxInstanceCount' on a repetition rule with value '0' is
Error message
A 'maxInstanceCount' on a repetition rule with value '0' is not allowed, either set it to '-1' or 'unlimited' or any other positive value..
What it means
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.
Source
Thrown at modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/RepetitionRuleXmlConverter.java:63
repetitionRule.setRepetitionCounterVariableName(xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE,
CmmnXmlConstants.ATTRIBUTE_REPETITION_COUNTER_VARIABLE_NAME));
String ignoreRepetitionCounterVariableValue = xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_IGNORE_REPETITION_COUNTER_VARIABLE);
if ("true".equalsIgnoreCase(ignoreRepetitionCounterVariableValue)) {
repetitionRule.setIgnoreRepetitionCounterVariable(true);
}
String maxInstanceCountValue = xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_REPETITION_MAX_INSTANCE_COUNT_NAME);
if (maxInstanceCountValue == null) {
repetitionRule.setMaxInstanceCount(null);
} else {
if (RepetitionRule.MAX_INSTANCE_COUNT_UNLIMITED_VALUE.equals(maxInstanceCountValue)) {
repetitionRule.setMaxInstanceCount(RepetitionRule.MAX_INSTANCE_COUNT_UNLIMITED);
} else {
int maxInstanceCount = Integer.parseInt(maxInstanceCountValue);
if (maxInstanceCount == 0) {
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..");
}
repetitionRule.setMaxInstanceCount(maxInstanceCount);
}
}
repetitionRule.setCollectionVariableName(xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE,
CmmnXmlConstants.ATTRIBUTE_REPETITION_COLLECTION_VARIABLE_NAME));
repetitionRule.setElementVariableName(xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE,
CmmnXmlConstants.ATTRIBUTE_REPETITION_ELEMENT_VARIABLE_NAME));
repetitionRule.setElementIndexVariableName(xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE,
CmmnXmlConstants.ATTRIBUTE_REPETITION_ELEMENT_INDEX_VARIABLE_NAME));
planItemControl.setRepetitionRule(repetitionRule);
return repetitionRule;
}View on GitHub (pinned to d6d39ce1c6)
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.
Example fix
// before <flowable:repetitionRule flowable:maxInstanceCount="0" /> // after <flowable:repetitionRule flowable:maxInstanceCount="3" />
Defensive patterns
Strategy: validation
Validate before calling
public static boolean isValidMaxInstanceCount(String v) {
if ("unlimited".equals(v)) return true;
try { return Integer.parseInt(v) != 0; } catch (NumberFormatException e) { return false; }
} Prevention
- 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
When it happens
Trigger: Converting CMMN XML where a <repetitionRule> (or its extension attribute) declares maxInstanceCount="0"; the value parses as an integer but equals 0.
Common situations: Modelers setting 'max instances' to 0 thinking it disables repetition; programmatic XML generation defaulting the counter to 0.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- There can only be one reactivation listener on a case model,
- Job {jobId} parent is not CMMN case
- Either set the user id or the group id for an identity link,
- There is no correlation parameter with name '${correlationPa
- externalJobId must not be empty
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/06db2c7601320264.
Report an issue: GitHub.