{"record":{"id":"2f151e2bcfdd5c93","repo":"zed-industries/zed","slug":"expected-to-render-a-table-row","errorCode":null,"errorMessage":"Expected to render a table row","messagePattern":"Expected to render a table row","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tabular_data_preview/src/renderer/render_table.rs","lineNumber":75,"sourceCode":"            .pin_cols(1)\n            .map(|table| {\n                let row_identifier_text_color = cx.theme().colors().editor_line_number;\n                match self.settings.rendering_with {\n                    RowRenderMechanism::VariableList => {\n                        table.variable_row_height_list(row_count, self.list_state.clone(), {\n                            cx.processor(move |this, display_row: usize, _window, cx| {\n                                this.performance_metrics.rendered_indices.push(display_row);\n\n                                let display_row = DisplayRow(display_row);\n                                Self::render_single_table_row(\n                                    this,\n                                    cols,\n                                    display_row,\n                                    row_identifier_text_color,\n                                    this.row_height,\n                                    cx,\n                                )\n                                .unwrap_or_else(|| panic!(\"Expected to render a table row\"))\n                            })\n                        })\n                    }\n                    RowRenderMechanism::UniformList => {\n                        table.uniform_list(\"tabular-data-table\", row_count, {\n                            cx.processor(move |this, range: Range<usize>, _window, cx| {\n                                // Record all display indices in the range for performance metrics\n                                this.performance_metrics\n                                    .rendered_indices\n                                    .extend(range.clone());\n\n                                let row_height = this.row_height;\n                                range\n                                    .filter_map(|display_index| {\n                                        Self::render_single_table_row(\n                                            this,\n                                            cols,\n                                            DisplayRow(display_index),","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/tabular_data_preview/src/renderer/render_table.rs#L57-L93","documentation":"The tabular data preview renders CSV/database tables in GPUI. In the table render mechanism each visible row goes through render_single_table_row, which returns Option; the render callback unwraps it and panics when None (crates/tabular_data_preview/src/renderer/render_table.rs:75). The panic means the component advertised row_count rows but could not produce one for an index GPUI asked to draw.","triggerScenarios":"The table element requests a display row the data source cannot resolve: the row_count passed to the table is larger than the rows the current snapshot can render (streaming/async data not yet loaded or truncated), or the display-row to data-row mapping returns None for a visible index.","commonSituations":"Previewing a file whose row count is initially estimated or changes mid-render; a background parse finishing while the frame renders; off-by-one in visible-range math for large files.","solutions":["Derive row_count and the render data from the same immutable snapshot so they cannot disagree within a frame.","If rows can be transiently unavailable, change render_single_table_row to return a placeholder element instead of None and drop the unwrap_or_else panic.","Reproduce with the triggering file and log the requested display row versus available rows to find which source (CSV reader, DB page) came up short.","Check visible-range arithmetic for an end one past the last row."],"exampleFix":"// before\n.unwrap_or_else(|| panic!(\"Expected to render a table row\"))\n\n// after\n.unwrap_or_else(|| empty_row_placeholder(row_height, cx))","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Derive row_count and render data from the same snapshot each frame.","Treat render callbacks as total over the advertised range.","Test previews with empty files, single-row files, and row counts that change while streaming.","Prefer returning a placeholder element over None in row renderers."],"tags":["gpui","render","table","csv-preview","panic","zed"],"backgroundTag":"render-invariant-violation","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}