{"record":{"id":"5f3d15b1e3bd01a9","repo":"deepset-ai/haystack","slug":"min-effective-lines-must-not-be-greater-than-max-e","errorCode":null,"errorMessage":"min_effective_lines must not be greater than max_effective_lines.","messagePattern":"min_effective_lines must not be greater than max_effective_lines\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"haystack/components/preprocessors/python_code_splitter.py","lineNumber":128,"sourceCode":"        :param strip_docstrings: If ``True``, function/method/class docstrings are moved\n            from the chunk content into ``meta[\"docstrings\"]`` (source order). The\n            module-level docstring is kept in place since it is itself a top-level unit.\n        :param preserve_class_definition: If ``True`` (default), chunks that contain class\n            members but not the class header are prefixed with the bare class signature\n            (decorators plus the ``class Foo(...):`` lines) in source order.\n        :param secondary_split_overlap: Line overlap for the secondary splitter; only used\n            in the oversized fallback. The primary AST split never adds overlap.\n        :param secondary_split_length: Lines per chunk for the secondary splitter.\n            Defaults to ``max_effective_lines`` when ``None``.\n        :raises ValueError: If any parameter is invalid (negative, zero where positive is\n            required, or ``min_effective_lines > max_effective_lines``).\n        \"\"\"\n        if min_effective_lines < 1:\n            raise ValueError(\"min_effective_lines must be at least 1.\")\n        if max_effective_lines < 1:\n            raise ValueError(\"max_effective_lines must be at least 1.\")\n        if min_effective_lines > max_effective_lines:\n            raise ValueError(\"min_effective_lines must not be greater than max_effective_lines.\")\n        if expected_chars_per_line < 1:\n            raise ValueError(\"expected_chars_per_line must be at least 1.\")\n        if oversized_factor < 1:\n            raise ValueError(\"oversized_factor must be at least 1.\")\n        if secondary_split_overlap < 0:\n            raise ValueError(\"secondary_split_overlap must be non-negative.\")\n        if secondary_split_length is not None and secondary_split_length < 1:\n            raise ValueError(\"secondary_split_length must be at least 1.\")\n\n        self.min_effective_lines = min_effective_lines\n        self.max_effective_lines = max_effective_lines\n        self.expected_chars_per_line = expected_chars_per_line\n        self.oversized_factor = oversized_factor\n        self.strip_docstrings = strip_docstrings\n        self.preserve_class_definition = preserve_class_definition\n        self.secondary_split_overlap = secondary_split_overlap\n        self.secondary_split_length = secondary_split_length\n","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/components/preprocessors/python_code_splitter.py#L110-L146","documentation":"PythonCodeSplitter's __init__ enforces min_effective_lines <= max_effective_lines. An inverted range is logically invalid for bounding chunk sizes, so ValueError is raised.","triggerScenarios":"Calling PythonCodeSplitter(min_effective_lines=20, max_effective_lines=10), or building both from config where the values were swapped or one was updated without the other.","commonSituations":"Swapped argument order in a positional call, config edits that raised min but not max, or programmatic shrinking of max below an existing min.","solutions":["Swap or correct the values so min <= max.","Add a caller-side check: assert min_effective_lines <= max_effective_lines before construction.","Update both bounds together when tuning chunk sizes.","Derive one from the other, e.g. max = min * 6, to keep the invariant."],"exampleFix":"// before\nPythonCodeSplitter(min_effective_lines=20, max_effective_lines=10)\n// after\nPythonCodeSplitter(min_effective_lines=5, max_effective_lines=30)","handlingStrategy":"validation","validationCode":"if min_effective_lines > max_effective_lines:\n    min_effective_lines, max_effective_lines = max_effective_lines, min_effective_lines","typeGuard":"def is_ordered_range(min_l, max_l) -> bool:\n    return isinstance(min_l, int) and isinstance(max_l, int) and 1 <= min_l <= max_l","tryCatchPattern":"try:\n    splitter = PythonCodeSplitter(min_effective_lines=min_l, max_effective_lines=max_l)\nexcept ValueError as e:\n    raise ConfigError(f\"Invalid line range: {e}\") from e","preventionTips":["Use keyword arguments to avoid swapping positional parameters.","Change min and max together when tuning.","Assert the invariant in config tests: min <= max."],"tags":["python","validation","range-invariant","haystack"],"backgroundTag":"invalid-constructor-argument","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}