zylon-ai/private-gpt · error · ValueError

Empty dataframe provided.

Error message

Empty dataframe provided.

What it means

TableNode.set_content validates the incoming TableNode.Meta and refuses an empty dataframe (len(value.dataframe) == 0), because a table node with zero rows has no content to index or serialize. It raises ValueError before any state is mutated. Typically the emptiness originates upstream — a query/filter that returned no rows, or a reader that produced an empty table from an empty file.

Source

Thrown at private_gpt/components/readers/nodes/table_node.py:342

                    for child in self.children
                )

        metadata_str = ""
        description = ""
        if metadata_mode != TreeMetadataMode.NONE:
            metadata_str = self.get_metadata_str(mode=metadata_mode).strip()
            description = (
                f"Table description: \n{self.description}\n" if self.description else ""
            )

        content = f"Content: \n{content}" if self.description else content
        return metadata_str + description + content

    def set_content(self, value: Any) -> None:
        if not isinstance(value, TableNode.Meta):
            raise ValueError(f"Expected TableNode.Meta, got {type(value)}")
        if len(value.dataframe) == 0:
            raise ValueError("Empty dataframe provided.")

        # Store content
        self.df = value.dataframe
        self.description = value.summary

    def is_row_compatible(self, row: TableRowNode) -> bool:
        return all(
            col1 == col2
            for col1, col2 in zip(self.df.columns, row.header, strict=False)
        )

    def add_row(self, row: list[Any]) -> None:
        if len(row) != len(self.df.columns):
            raise ValueError(
                f"Row length mismatch: {len(row)} != {len(self.df.columns)}"
            )
        self.df.loc[len(self.df)] = row

View on GitHub (pinned to 4a030776a3)

Solutions

  1. Skip table-node creation when the frame is empty: `if len(df) == 0: return` (or log and drop the document).
  2. Fix the upstream reader/delimiter config if the source file genuinely has rows but none are parsed (wrong separator, wrong encoding).
  3. If an empty table must be represented, emit metadata/description only rather than a TableNode.
  4. Validate the source export job so header-only files are not generated.

Example fix

# before
node.set_content(TableNode.Meta(dataframe=df, summary="..."))  # ValueError: Empty dataframe

# after
if len(df) == 0:
    logger.warning("Skipping empty table for %s", source_name)
else:
    node.set_content(TableNode.Meta(dataframe=df, summary="..."))
Defensive patterns

Strategy: validation

Validate before calling

def build_table_node(df, summary: str) -> TableNode | None:
    if df is None or len(df) == 0:
        logger.warning("Empty dataframe; skipping table node")
        return None
    node = TableNode()
    node.set_content(TableNode.Meta(dataframe=df, summary=summary))
    return node

Type guard

def is_nonempty_dataframe(value: Any) -> bool:
    import pandas as pd
    return isinstance(value, pd.DataFrame) and len(value) > 0

Try / catch

try:
    table_node.set_content(meta)
except ValueError as e:
    if "Empty dataframe" in str(e):
        skip_document = True  # known-benign: header-only source
    else:
        raise

Prevention

When it happens

Trigger: Calling TableNode.set_content(meta) where meta.dataframe is an empty DataFrame — e.g. ingesting a header-only CSV, applying a filter that drops all rows, or programmatically constructing a Meta from `pd.DataFrame()`.

Common situations: Ingesting empty CSV/TSV exports (common with scheduled jobs that had no data); delimiter misconfiguration producing zero parsed rows; ETL filters that occasionally empty the frame; test fixtures with empty dataframes.

Related errors


AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15). Data as JSON: /api/errors/69cff3495f05ce73. Report an issue: GitHub.