deepset-ai/haystack · error · ValueError

column_split_threshold must be greater than 0

Error message

column_split_threshold must be greater than 0

What it means

CSVDocumentSplitter requires column_split_threshold to be None or >= 1; values less than 1 raise ValueError in __init__. This threshold counts consecutive empty columns that trigger a split.

Source

Thrown at haystack/components/preprocessors/csv_document_splitter.py:64

            - `header=None`
            - `skip_blank_lines=False` to preserve blank lines
            - `dtype=object` to prevent type inference (e.g., converting numbers to floats).
            See https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html for more information.
        :param split_mode:
            If `threshold`, the component will split the document based on the number of
            consecutive empty rows or columns that exceed the `row_split_threshold` or `column_split_threshold`.
            If `row-wise`, the component will split each row into a separate sub-table.
        """
        pandas_import.check()
        if split_mode not in get_args(SplitMode):
            raise ValueError(
                f"Split mode '{split_mode}' not recognized. Choose one among: {', '.join(get_args(SplitMode))}."
            )
        if row_split_threshold is not None and row_split_threshold < 1:
            raise ValueError("row_split_threshold must be greater than 0")

        if column_split_threshold is not None and column_split_threshold < 1:
            raise ValueError("column_split_threshold must be greater than 0")

        if row_split_threshold is None and column_split_threshold is None:
            raise ValueError("At least one of row_split_threshold or column_split_threshold must be specified.")

        self.row_split_threshold = row_split_threshold
        self.column_split_threshold = column_split_threshold
        self.read_csv_kwargs = read_csv_kwargs or {}
        self.split_mode = split_mode

    @component.output_types(documents=list[Document])
    def run(self, documents: list[Document]) -> dict[str, list[Document]]:
        """
        Processes and splits a list of CSV documents into multiple sub-tables.

        **Splitting Process:**
        1. Applies a row-based split if `row_split_threshold` is provided.
        2. Applies a column-based split if `column_split_threshold` is provided.
        3. If both thresholds are specified, performs a recursive split by rows first, then columns, ensuring

View on GitHub (pinned to e318778c9b)

Solutions

  1. Set column_split_threshold to an integer >= 1 or None.
  2. Pass None (not 0) to disable column-based splitting.
  3. Remember at least one of row/column threshold must be non-None.

Example fix

// before
CSVDocumentSplitter(split_mode="threshold", column_split_threshold=0, row_split_threshold=2)
// after
CSVDocumentSplitter(split_mode="threshold", column_split_threshold=None, row_split_threshold=2)
Defensive patterns

Strategy: validation

Validate before calling

if column_split_threshold is not None and column_split_threshold < 1:
    raise ValueError("column_split_threshold must be >= 1 or None")
splitter = CSVDocumentSplitter(split_mode="threshold", column_split_threshold=col_t, row_split_threshold=row_t)

Type guard

def is_valid_threshold(v: int | None) -> bool:
    return v is None or (isinstance(v, int) and v >= 1)

Try / catch

try:
    splitter = CSVDocumentSplitter(split_mode="threshold", column_split_threshold=t)
except ValueError as e:
    logger.warning("invalid column_split_threshold %r: %s", t, e)
    splitter = CSVDocumentSplitter(split_mode="threshold", column_split_threshold=None, row_split_threshold=2)

Prevention

When it happens

Trigger: CSVDocumentSplitter(column_split_threshold=0) or a negative number, usually in 'threshold' split mode.

Common situations: Zero used as a 'disable' placeholder instead of None; config parsing yielding 0; misunderstanding that 1 is the minimum meaningful count.

Understand the failure class

Background: "must be positive", "Invalid value": how libraries reject invalid parameter values (ValueError, ArgumentError, INVALID_PARAMETER_VALUE) — this error's family across 28 libraries.

Related errors


AI-assisted analysis of deepset-ai/haystack@e318778c9b (2026-08-30). Data as JSON: /api/errors/845dd8e1d577dc6e. Report an issue: GitHub.