{"record":{"id":"a106f24011984a2c","repo":"Textualize/textual","slug":"more-values-provided-than-there-are-columns","errorCode":null,"errorMessage":"More values provided than there are columns.","messagePattern":"More values provided than there are columns\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/textual/widgets/_data_table.py","lineNumber":1700,"sourceCode":"            key: A key which uniquely identifies this row. If None, it will be generated\n                for you and returned.\n            label: The label for the row. Will be displayed to the left if supplied.\n\n        Returns:\n            Unique identifier for this row. Can be used to retrieve this row regardless\n                of its current location in the DataTable (it could have moved after\n                being added due to sorting or insertion/deletion of other rows).\n        \"\"\"\n        row_key = RowKey(key)\n        if row_key in self._row_locations:\n            raise DuplicateKey(f\"The row key {row_key!r} already exists.\")\n\n        # TODO: If there are no columns: do we generate them here?\n        #  If we don't do this, users will be required to call add_column(s)\n        #  Before they call add_row.\n\n        if len(cells) > len(self.ordered_columns):\n            raise ValueError(\"More values provided than there are columns.\")\n\n        row_index = self.row_count\n        # Map the key of this row to its current index\n        self._row_locations[row_key] = row_index\n        self._data[row_key] = {\n            column.key: cell\n            for column, cell in zip_longest(self.ordered_columns, cells)\n        }\n\n        label = Text.from_markup(label, end=\"\") if isinstance(label, str) else label\n\n        # Rows with auto-height get a height of 0 because 1) we need an integer height\n        # to do some intermediate computations and 2) because 0 doesn't impact the data\n        # table while we don't figure out how tall this row is.\n        self.rows[row_key] = Row(\n            row_key,\n            height or 0,\n            label,","sourceCodeStart":1682,"sourceCodeEnd":1718,"githubUrl":"https://github.com/Textualize/textual/blob/06dbeef4bb70fb718236aa418ed658ef4667a126/src/textual/widgets/_data_table.py#L1682-L1718","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"# before\ntable.add_row(*record.values())\n\n# after\nvalues = list(record.values())[:len(table.columns)]\ntable.add_row(*values)","handlingStrategy":"validation","validationCode":"assert len(values) <= len(table.columns), 'row wider than schema'\ntable.add_row(*values)","typeGuard":null,"tryCatchPattern":"try:\n    table.add_row(*values)\nexcept ValueError as e:\n    if 'More values' in str(e):\n        table.add_row(*values[: len(table.columns)])\n    else:\n        raise","preventionTips":["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"],"tags":["data-table","value-error","textual","schema-mismatch"],"backgroundTag":"schema-validation-failed","analyzedSha":"06dbeef4bb70fb718236aa418ed658ef4667a126","analyzedAt":"2026-08-27T02:36:57.214Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}