{"record":{"id":"c68d9fe9edc6d2d5","repo":"apache/seatunnel","slug":"maxlines-must-be-1","errorCode":null,"errorMessage":"maxLines must be >= 1","messagePattern":"maxLines must be >= 1","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-edge-agent/seatunnel-edge-agent-connector/src/main/java/org/apache/seatunnel/edge/agent/connector/file/multiline/MultilineAssembler.java","lineNumber":78,"sourceCode":"    }\n\n    private final Pattern pattern;\n    private final MatchMode matchMode;\n    private final boolean negate;\n    private final int maxLines;\n    private final List<LineElement> buffer;\n\n    /**\n     * @param regex pattern applied to each line's text (via {@code Pattern.matcher} {@code\n     *     .find()})\n     * @param matchMode AFTER or BEFORE semantics (see {@link MatchMode})\n     * @param negate if true, pattern match is inverted\n     * @param maxLines maximum number of lines to retain in the buffer before forcing a flush (must\n     *     be {@code >= 1})\n     */\n    public MultilineAssembler(String regex, MatchMode matchMode, boolean negate, int maxLines) {\n        if (maxLines < 1) {\n            throw new IllegalArgumentException(\"maxLines must be >= 1\");\n        }\n        this.pattern = Pattern.compile(Objects.requireNonNull(regex, \"regex\"));\n        this.matchMode = Objects.requireNonNull(matchMode, \"matchMode\");\n        this.negate = negate;\n        this.maxLines = maxLines;\n        this.buffer = new ArrayList<>();\n    }\n\n    /**\n     * Feeds one physical line into the assembler.\n     *\n     * @return a new list containing the completed prior event if this line triggered a flush, or\n     *     {@code null} if the line was only buffered and no event completed yet\n     */\n    public List<LineElement> addLine(LineElement line) {\n        boolean matches = pattern.matcher(line.getText()).find();\n        if (negate) {\n            matches = !matches;","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-edge-agent/seatunnel-edge-agent-connector/src/main/java/org/apache/seatunnel/edge/agent/connector/file/multiline/MultilineAssembler.java#L60-L96","documentation":"MultilineAssembler's constructor validates that the buffer line cap is at least 1, because an assembler that retains zero lines could never emit an event. Throwing immediately at construction turns a misconfiguration into a fast, clear failure instead of silent misbehavior during file tailing.","triggerScenarios":"Calling new MultilineAssembler(regex, matchMode, negate, maxLines) with maxLines < 1 (typically 0 or a negative value parsed from a user-supplied multiline config option).","commonSituations":"agent.yaml multiline.max-lines set to 0 or a negative number by mistake; an int-parsed config default of 0 when the user forgot to set the value; off-by-one arithmetic when deriving maxLines from another setting.","solutions":["Set maxLines to a positive integer (>= 1) in the constructor call or the underlying config","Validate/clamp the config value when parsing agent.yaml before constructing the assembler","Add a config-level check that rejects maxLines <= 0 with a message naming the config key"],"exampleFix":"// before\nMultilineAssembler assembler = new MultilineAssembler(pattern, matchMode, false, maxLines);\n// after\nint safeMaxLines = Math.max(1, maxLines);\nMultilineAssembler assembler = new MultilineAssembler(pattern, matchMode, false, safeMaxLines);","handlingStrategy":"validation","validationCode":"if (maxLines < 1) {\n    throw new IllegalArgumentException(\"maxLines must be >= 1, got: \" + maxLines);\n}\nnew MultilineAssembler(regex, matchMode, negate, maxLines);","typeGuard":"boolean isValidMaxLines(Integer v) { return v != null && v >= 1; }","tryCatchPattern":null,"preventionTips":["Validate multiline.max-lines at config load time","Use a config Option with a sane default (e.g. 125) instead of 0","Never construct assemblers directly from raw user input without clamping"],"tags":["java","configuration","validation"],"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-14T16:17:12.679Z"}