{"record":{"id":"b3feab8930f8049f","repo":"apache/seatunnel","slug":"bytespersecond-and-countpersecond-must-be-positive","errorCode":null,"errorMessage":"bytesPerSecond and countPerSecond must be positive","messagePattern":"bytesPerSecond and countPerSecond must be positive","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-core/seatunnel-core-starter/src/main/java/org/apache/seatunnel/core/starter/flowcontrol/FlowControlStrategy.java","lineNumber":36,"sourceCode":"package org.apache.seatunnel.core.starter.flowcontrol;\n\nimport org.apache.seatunnel.shade.com.typesafe.config.Config;\n\nimport java.util.Map;\nimport java.util.Optional;\n\nimport static org.apache.seatunnel.api.options.EnvCommonOptions.READ_LIMIT_BYTES_PER_SECOND;\nimport static org.apache.seatunnel.api.options.EnvCommonOptions.READ_LIMIT_ROW_PER_SECOND;\n\npublic final class FlowControlStrategy {\n\n    private final int bytesPerSecond;\n\n    private final int countPerSecond;\n\n    FlowControlStrategy(int bytesPerSecond, int countPerSecond) {\n        if (bytesPerSecond <= 0 || countPerSecond <= 0) {\n            throw new IllegalArgumentException(\n                    \"bytesPerSecond and countPerSecond must be positive\");\n        }\n        this.bytesPerSecond = bytesPerSecond;\n        this.countPerSecond = countPerSecond;\n    }\n\n    public int getBytesPerSecond() {\n        return bytesPerSecond;\n    }\n\n    public int getCountPerSecond() {\n        return countPerSecond;\n    }\n\n    public static Builder builder() {\n        return new Builder();\n    }\n","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-core/seatunnel-core-starter/src/main/java/org/apache/seatunnel/core/starter/flowcontrol/FlowControlStrategy.java#L18-L54","documentation":"FlowControlStrategy's constructor requires both rate limits to be strictly positive. It throws IllegalArgumentException when either bytesPerSecond or countPerSecond is zero or negative, because a flow-control strategy with no throughput or no per-second count would stall all traffic.","triggerScenarios":"Calling new FlowControlStrategy(x, y) where x <= 0 or y <= 0, e.g. parsing a seatunnel flow-control config with bytes-per-second: 0 or a negative count-per-second.","commonSituations":"Users set flow-control options to 0 intending 'unlimited', paste negative values from YAML arithmetic, or default placeholders that were never filled in.","solutions":["Pass strictly positive values for both bytesPerSecond and countPerSecond","Treat 'unlimited' as disabling flow control upstream rather than passing 0","Validate config values (positive int) before constructing the strategy"],"exampleFix":"// before\nFlowControlStrategy strategy = new FlowControlStrategy(0, 100);\n// after\nlong bytes = config.getLong(\"bytes-per-second\");\nif (bytes <= 0) { bytes = Integer.MAX_VALUE; } // or skip flow control entirely\nFlowControlStrategy strategy = new FlowControlStrategy((int) bytes, 100);","handlingStrategy":"validation","validationCode":"if (bytesPerSecond <= 0 || countPerSecond <= 0) throw new IllegalArgumentException(\"flow control rates must be > 0\");","typeGuard":null,"tryCatchPattern":"try { new FlowControlStrategy(bps, cps); } catch (IllegalArgumentException e) { log.error(\"Bad flow-control config: {}\", e.getMessage()); }","preventionTips":["Validate rate options are positive integers when parsing config","Map 'unlimited' to disabling flow control, not 0","Add config-schema checks for byte/time units"],"tags":["flow-control","illegal-argument","configuration"],"backgroundTag":"invalid-config-value","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}