Textualize/textual · error · ValueError
More values provided than there are columns.
Error message
More values provided than there are columns.
What it means
A plain ValueError raised by DataTable.add_row when len(cells) exceeds the number of defined columns. Rows are positionally matched to ordered_columns, so passing more values than add_column calls made earlier is a programming error.
Source
Thrown at src/textual/widgets/_data_table.py:1700
key: A key which uniquely identifies this row. If None, it will be generated
for you and returned.
label: The label for the row. Will be displayed to the left if supplied.
Returns:
Unique identifier for this row. Can be used to retrieve this row regardless
of its current location in the DataTable (it could have moved after
being added due to sorting or insertion/deletion of other rows).
"""
row_key = RowKey(key)
if row_key in self._row_locations:
raise DuplicateKey(f"The row key {row_key!r} already exists.")
# TODO: If there are no columns: do we generate them here?
# If we don't do this, users will be required to call add_column(s)
# Before they call add_row.
if len(cells) > len(self.ordered_columns):
raise ValueError("More values provided than there are columns.")
row_index = self.row_count
# Map the key of this row to its current index
self._row_locations[row_key] = row_index
self._data[row_key] = {
column.key: cell
for column, cell in zip_longest(self.ordered_columns, cells)
}
label = Text.from_markup(label, end="") if isinstance(label, str) else label
# Rows with auto-height get a height of 0 because 1) we need an integer height
# to do some intermediate computations and 2) because 0 doesn't impact the data
# table while we don't figure out how tall this row is.
self.rows[row_key] = Row(
row_key,
height or 0,
label,View on GitHub (pinned to 06dbeef4bb)
Solutions
- Ensure all add_column calls complete before any add_row.
- Normalize row data: trim or validate len(values) <= len(table.columns) before adding.
- If extra fields are legitimate, add the missing columns first or slice values to the column count.
- Add a unit test asserting row width matches schema width.
Example fix
# before table.add_row(*record.values()) # after values = list(record.values())[:len(table.columns)] table.add_row(*values)
Defensive patterns
Strategy: validation
Validate before calling
assert len(values) <= len(table.columns), 'row wider than schema' table.add_row(*values)
Try / catch
try:
table.add_row(*values)
except ValueError as e:
if 'More values' in str(e):
table.add_row(*values[: len(table.columns)])
else:
raise Prevention
- Add all columns before any rows
- Normalize record width to the schema before add_row
- Unit-test row width against schema for dynamic data sources
When it happens
Trigger: Calling add_row with more positional cell values than the table has columns; adding rows before all columns are added; data rows whose length varies (e.g. ragged CSV/JSON input).
Common situations: Building the table from dynamic data where a record has extra fields; forgetting to add a column added later to the data model; ordering bugs where add_row runs before all add_column calls.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Row key {row_key!r} is not valid.
- Row index {row_index!r} is not valid.
- No row exists for row_key={row_key!r}
- Column key {column_key!r} is not valid.
- Column index {column_index!r} is not valid.
AI-assisted analysis of Textualize/textual@06dbeef4bb (2026-08-27).
Data as JSON: /api/errors/a106f24011984a2c.
Report an issue: GitHub.