{"record":{"id":"25a1ea26523fec5b","repo":"Textualize/textual","slug":"no-cell-exists-at-coordinate-r","errorCode":null,"errorMessage":"No cell exists at {coordinate!r}.","messagePattern":"No cell exists at (.+?)\\.","errorType":"exception","errorClass":"CellDoesNotExist","httpStatus":null,"severity":"error","filePath":"src/textual/widgets/_data_table.py","lineNumber":1291,"sourceCode":"                DataTable.CellHighlighted(\n                    self, cell_value, coordinate=coordinate, cell_key=cell_key\n                )\n            )\n\n    def coordinate_to_cell_key(self, coordinate: Coordinate) -> CellKey:\n        \"\"\"Return the key for the cell currently occupying this coordinate.\n\n        Args:\n            coordinate: The coordinate to exam the current cell key of.\n\n        Returns:\n            The key of the cell currently occupying this coordinate.\n\n        Raises:\n            CellDoesNotExist: If the coordinate is not valid.\n        \"\"\"\n        if not self.is_valid_coordinate(coordinate):\n            raise CellDoesNotExist(f\"No cell exists at {coordinate!r}.\")\n        row_index, column_index = coordinate\n        row_key = self._row_locations.get_key(row_index)\n        column_key = self._column_locations.get_key(column_index)\n        return CellKey(row_key, column_key)\n\n    def _highlight_row(self, row_index: int) -> None:\n        \"\"\"Apply highlighting to the row at the given index, and post event.\"\"\"\n        self.refresh_row(row_index)\n        is_valid_row = row_index < len(self._data)\n        if is_valid_row:\n            row_key = self._row_locations.get_key(row_index)\n            self.post_message(DataTable.RowHighlighted(self, row_index, row_key))\n\n    def _highlight_column(self, column_index: int) -> None:\n        \"\"\"Apply highlighting to the column at the given index, and post event.\"\"\"\n        self.refresh_column(column_index)\n        if column_index < len(self.columns):\n            column_key = self._column_locations.get_key(column_index)","sourceCodeStart":1273,"sourceCodeEnd":1309,"githubUrl":"https://github.com/Textualize/textual/blob/06dbeef4bb70fb718236aa418ed658ef4667a126/src/textual/widgets/_data_table.py#L1273-L1309","documentation":"Raised by DataTable.coordinate_to_cell_key when the given Coordinate (row_index, column_index) fails is_valid_coordinate. This converts a screen-space cell position into its stable CellKey; invalid coordinates are any position outside the current row/column grid.","triggerScenarios":"Calling coordinate_to_cell_key with out-of-range row or column indices, e.g. from mouse event coordinate math, stale cursor positions, or coordinates computed before rows/columns were removed.","commonSituations":"Translating DataTable.CellSelected/CursorMoved event coordinates after the table shrank; handling mouse clicks while async updates remove rows; manually constructing Coordinate objects from widget-relative math.","solutions":["Validate first: table.is_valid_coordinate(coordinate).","Re-check row_count/column counts after async mutations before converting coordinates.","Catch CellDoesNotExist around event handling that may race with table updates.","Derive coordinates from table events rather than computing them by hand."],"exampleFix":"# before\ncell_key = table.coordinate_to_cell_key(coordinate)\n\n# after\nfrom textual.widgets._data_table import CellDoesNotExist\ntry:\n    cell_key = table.coordinate_to_cell_key(coordinate)\nexcept CellDoesNotExist:\n    cell_key = None","handlingStrategy":"validation","validationCode":"cell_key = table.coordinate_to_cell_key(coord) if table.is_valid_coordinate(coord) else None","typeGuard":null,"tryCatchPattern":"from textual.widgets._data_table import CellDoesNotExist\ntry:\n    cell_key = table.coordinate_to_cell_key(coord)\nexcept CellDoesNotExist:\n    cell_key = None","preventionTips":["Always call is_valid_coordinate before conversion","Use event-provided coordinates rather than computing them manually","Re-validate after async table mutations"],"tags":["data-table","coordinate","textual","cell"],"backgroundTag":"index-out-of-range","analyzedSha":"06dbeef4bb70fb718236aa418ed658ef4667a126","analyzedAt":"2026-08-27T02:36:57.214Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}