{"record":{"id":"af36cbd5aa0521e0","repo":"BookStackApp/BookStack","slug":"tablemap-error-attempted-to-get-cell-position-1","errorCode":null,"errorMessage":"TableMap Error: Attempted to get cell ${position+1} of ${this.cells.length}","messagePattern":"TableMap Error: Attempted to get cell (.+?) of (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"resources/js/wysiwyg/utils/table-map.ts","lineNumber":79,"sourceCode":"        let lastCell: TableCellNode = rowsAndCells[0][0];\n        for (let y = 0; y < this.rowCount; y++) {\n            for (let x = 0; x < this.columnCount; x++) {\n                if (!rowsAndCells[y] || !rowsAndCells[y][x]) {\n                    cells.push(lastCell);\n                } else {\n                    cells.push(rowsAndCells[y][x]);\n                    lastCell = rowsAndCells[y][x];\n                }\n            }\n        }\n\n        this.cells = cells;\n    }\n\n    public getCellAtPosition(x: number, y: number): TableCellNode {\n        const position = (y * this.columnCount) + x;\n        if (position >= this.cells.length) {\n            throw new Error(`TableMap Error: Attempted to get cell ${position+1} of ${this.cells.length}`);\n        }\n\n        return this.cells[position];\n    }\n\n    public getCellsInRange(range: CellRange): TableCellNode[] {\n        const minX = Math.max(Math.min(range.fromX, range.toX), 0);\n        const maxX = Math.min(Math.max(range.fromX, range.toX), this.columnCount - 1);\n        const minY = Math.max(Math.min(range.fromY, range.toY), 0);\n        const maxY = Math.min(Math.max(range.fromY, range.toY), this.rowCount - 1);\n\n        const cells = new Set<TableCellNode>();\n\n        for (let y = minY; y <= maxY; y++) {\n            for (let x = minX; x <= maxX; x++) {\n                cells.add(this.getCellAtPosition(x, y));\n            }\n        }","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/BookStackApp/BookStack/blob/18f8469a1c72f8cc8497e9372635e6dea5028071/resources/js/wysiwyg/utils/table-map.ts#L61-L97","documentation":"Bounds guard in TableMap.getCellAtPosition: the computed (y*columnCount)+x position is >= the filled cell list length, i.e. a lookup ran past the table map's known cells — usually after the map went stale relative to the actual table DOM/nodes. Input at fault: x/y coordinates outside the mapped grid.","triggerScenarios":"Thrown at resources/js/wysiwyg/utils/table-map.ts:79 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rebuild the TableMap from the current table DOM before cell lookups","Clamp x/y to rowCount-1/columnCount-1 before calling getCellAtPosition","Check the callers (relCell, getCellsInRange, headCell) use valid in-range coordinates"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"18f8469a1c72f8cc8497e9372635e6dea5028071","analyzedAt":"2026-09-02T19:49:33.068Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}