{"record":{"id":"7f9bd27d6ff35837","repo":"flowable/flowable-engine","slug":"the-maximum-allowed-length-must-be-greater-than-0","errorCode":null,"errorMessage":"The maximum allowed length must be greater than 0","messagePattern":"The maximum allowed length must be greater than 0","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/variable/MaxAllowedLengthVariableVerifier.java","lineNumber":30,"sourceCode":" */\npackage org.flowable.common.engine.impl.variable;\n\nimport org.apache.commons.lang3.StringUtils;\nimport org.flowable.common.engine.api.FlowableIllegalArgumentException;\nimport org.flowable.common.engine.api.scope.ScopeTypes;\nimport org.flowable.variable.api.types.ValueFields;\nimport org.flowable.variable.api.types.VariableType;\n\n/**\n * @author Filip Hrisafov\n */\npublic class MaxAllowedLengthVariableVerifier implements VariableLengthVerifier {\n\n    protected final int maxAllowedLength;\n\n    public MaxAllowedLengthVariableVerifier(int maxAllowedLength) {\n        if (maxAllowedLength <= 0) {\n            throw new FlowableIllegalArgumentException(\"The maximum allowed length must be greater than 0\");\n        }\n        this.maxAllowedLength = maxAllowedLength;\n    }\n\n    @Override\n    public void verifyLength(int length, ValueFields valueFields, VariableType variableType) {\n        if (length > maxAllowedLength) {\n            String scopeId;\n            String scopeType;\n            if (StringUtils.isNotEmpty(valueFields.getTaskId())) {\n                scopeId = valueFields.getTaskId();\n                scopeType = ScopeTypes.TASK;\n            } else if (StringUtils.isNotEmpty(valueFields.getProcessInstanceId())) {\n                scopeId = valueFields.getProcessInstanceId();\n                scopeType = ScopeTypes.BPMN;\n            } else {\n                scopeId = valueFields.getScopeId();\n                scopeType = valueFields.getScopeType();","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/variable/MaxAllowedLengthVariableVerifier.java#L12-L48","documentation":"Constructor guard: MaxAllowedLengthVariableVerifier rejects a configured maximum length of zero or negative at construction time. The verifier exists to enforce DB column length limits for variables; an unusable limit is refused immediately.","triggerScenarios":"Creating a MaxAllowedLengthVariableVerifier (directly or via engine configuration wiring a variable length verifier) with maxAllowedLength <= 0.","commonSituations":"Configuration mistakes like 0 or -1 placeholders; computing the limit from a property that failed to parse; copy-paste of the wrong constant.","solutions":["Pass a positive integer for maxAllowedLength (e.g. the DB column length, commonly 4001 for text columns)","Check the config property feeding the value — ensure it parses to the intended positive number","Remove/omit the verifier if no length limit is needed"],"exampleFix":"// before\nnew MaxAllowedLengthVariableVerifier(0);\n// after\nnew MaxAllowedLengthVariableVerifier(4001);","handlingStrategy":"validation","validationCode":"if (maxAllowedLength == null || maxAllowedLength <= 0)\n    throw new IllegalArgumentException(\"maxAllowedLength must be > 0, got: \" + maxAllowedLength);","typeGuard":"boolean isValidMaxLength(Integer len) {\n    return len != null && len > 0;\n}","tryCatchPattern":"try {\n    new MaxAllowedLengthVariableVerifier(cfgLen);\n} catch (FlowableIllegalArgumentException e) {\n    logger.error(\"Invalid verifier limit, falling back to default\", e);\n    verifier = new MaxAllowedLengthVariableVerifier(4001);\n}","preventionTips":["Wire the limit from the actual DB column size","Validate config properties parse to positive integers","Never use 0/-1 as placeholder limits"],"tags":["validation","configuration","variables"],"backgroundTag":"invalid-config-value","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"}