fix(data-editor): don't crash appending a row to an empty row-oriented editor - #10651
Draft
winklemad wants to merge 1 commit into
Draft
fix(data-editor): don't crash appending a row to an empty row-oriented editor#10651winklemad wants to merge 1 commit into
winklemad wants to merge 1 commit into
Conversation
…d editor Appending a positional edit to an empty row-oriented data editor raised IndexError because the new row's columns were read from data[0], which does not exist when there are no rows yet. Derive the columns from the schema when available and always include the edited column, mirroring the column-oriented path. This also fixes the remove-all-then-add edit replay.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
kirangadhave
requested review from
kirangadhave
and
a lite review from Copilot
August 25, 2026 15:44
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a crash when appending the first row in an empty row-oriented data editor.
Changes:
- Adds fallback logic for empty row-oriented appends.
- Adds regression tests for empty and remove-all-then-add scenarios.
- Critical issue: replay via
_convert_valuecan still drop existing columns because no schema is preserved or passed.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Summary |
|---|---|
tests/_plugins/ui/_impl/test_data_editor.py |
Adds regression coverage for empty-row appends. |
marimo/_plugins/ui/_impl/data_editor.py |
Updates empty-row append handling; requires preserving or passing the original editor schema and testing _convert_value. |
Suppressed comments (3)
marimo/_plugins/ui/_impl/data_editor.py:471
- This still appends only one row for every
rowIdx >= len(data). For example, an empty row-oriented input withrowIdx: 1reachesdata[1]after this append and raisesIndexError; the column-oriented path extends through the requested index. Extend byrowIdx - len(data) + 1rows (or reject non-contiguous indices) so the guarded branch is correct for all out-of-range positional edits.
new_row: dict[str, Any] = {col: None for col in columns}
new_row.setdefault(edit["columnId"], None)
data.append(new_row)
marimo/_plugins/ui/_impl/data_editor.py:471
- This fallback only adds the column from the first edit. If one edit batch contains multiple cells for the first new row, the next column enters the existing-row path and
data[0][columnId]raisesKeyError. The UI's row-add replay emits one positional edit per column, so remove-all-then-add with a multi-column row still crashes; ensure the target row contains the column before reading/updating it and add that regression case.
new_row: dict[str, Any] = {col: None for col in columns}
new_row.setdefault(edit["columnId"], None)
data.append(new_row)
marimo/_plugins/ui/_impl/data_editor.py:466
nw.Schemaexposes its column names throughnames()(as used elsewhere in this codebase), notkeys(). This makes the new schema fallback raiseAttributeErrorbefore appending, so the added_with_schemaregression test fails; useschema.names()here.
columns = list(schema.keys())
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+465
to
+466
| elif schema is not None: | ||
| columns = list(schema.keys()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request was authored by a coding agent.
📝 Summary
Closes #10650
_apply_positional_edit_row_orientedcrashed withIndexErrorwhen appending a new row to an empty row-oriented editor: it built the new row fromdata[0], which raises on an empty list. This is reachable from the UI by deleting all rows and then adding one.When there is no existing row to read column names from, this falls back to the editor's schema (and always includes the edited column), so appending the first row works. The column-oriented path already handled the empty case.
📋 Pre-Review Checklist
✅ Merge Checklist