{"record":{"id":"679a999d8d7835fd","repo":"aaif-goose/goose","slug":"range-contains-cell-count-cells-maximum-is-max","errorCode":null,"errorMessage":"Range contains {cell_count} cells; maximum is {MAX_RANGE_CELLS}","messagePattern":"Range contains (.+?) cells; maximum is (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/goose-mcp/src/computercontroller/xlsx_tool.rs","lineNumber":256,"sourceCode":"        \"Column must be between 1 and {MAX_EXCEL_COLUMNS}\"\n    );\n    anyhow::ensure!(\n        start_row <= end_row && start_col <= end_col,\n        \"Range start must not follow range end\"\n    );\n\n    let row_count = end_row\n        .checked_sub(start_row)\n        .and_then(|span| span.checked_add(1))\n        .context(\"Row span overflow\")?;\n    let column_count = end_col\n        .checked_sub(start_col)\n        .and_then(|span| span.checked_add(1))\n        .context(\"Column span overflow\")?;\n    let cell_count = u64::from(row_count)\n        .checked_mul(u64::from(column_count))\n        .context(\"Range area overflow\")?;\n    anyhow::ensure!(\n        cell_count <= MAX_RANGE_CELLS,\n        \"Range contains {cell_count} cells; maximum is {MAX_RANGE_CELLS}\"\n    );\n\n    Ok((row_count, column_count))\n}\n\nfn parse_cell_reference(reference: &str) -> Result<(u32, u32)> {\n    // Parse Excel cell reference (e.g., \"A1\") and return (row, column) to match umya_spreadsheet's expectation\n    let mut col_str = String::new();\n    let mut row_str = String::new();\n    let mut parsing_row = false;\n\n    for c in reference.chars() {\n        if c.is_alphabetic() {\n            if parsing_row {\n                anyhow::bail!(\"Invalid cell reference format\");\n            }","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/crates/goose-mcp/src/computercontroller/xlsx_tool.rs#L238-L274","documentation":"validate_range_bounds() computes the range area as row_count * column_count (with checked arithmetic) and enforces MAX_RANGE_CELLS = 100_000 (xlsx_tool.rs:8). Larger ranges bail with the actual cell count and the limit. This is a resource guard: reading a huge range would build a massive Vec of cell values in memory.","triggerScenarios":"Ranges like 'A1:XFD1048576' (full sheet, ~17.2B cells), 'A1:Z100000' (2.6M cells), or 'A1:A100001' (100_001 cells, one over). Even if the worksheet is mostly empty, the REQUESTED rectangle is what is counted.","commonSituations":"Agents requesting 'all data' as a full-sheet range; whole-column reads ('A:A' style translated to max rows); users expecting the tool to return megabyte-scale exports in one call.","solutions":["Shrink the range to at most 100_000 cells (e.g. 'A1:Z2000' is 52_000).","Page through data in chunks: iterate row windows of a few thousand rows.","Use the worksheet dimensions (highest_row/highest_column) to bound the range to the actually used area.","For exports, prefer file-level operations over reading every cell."],"exampleFix":"// before\nlet range = \"A1:XFD1048576\"; // ~17 billion cells -> 'Range contains ... cells; maximum is 100000'\n\n// after\nlet range = \"A1:Z2000\"; // 52_000 cells, within the 100_000 limit","handlingStrategy":"validation","validationCode":"const MAX_RANGE_CELLS: u64 = 100_000;\nfn cell_count(sr: u32, sc: u32, er: u32, ec: u32) -> u64 {\n    u64::from(er - sr + 1) * u64::from(ec - sc + 1)\n}\nif cell_count(sr, sc, er, ec) > MAX_RANGE_CELLS {\n    // clamp rows so area fits the budget, e.g. full-width reads:\n    let cols = ec - sc + 1;\n    let max_rows = (MAX_RANGE_CELLS / u64::from(cols)) as u32;\n    er = (er.min(sr + max_rows - 1));\n}\nlet range = format!(\"{}{}:{}{}\", col_name(sc), sr, col_name(ec), er);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Budget reads to at most 100_000 cells per call (rows x cols <= 100_000).","Bound ranges by the worksheet's used area (highest_row/highest_column), not the full grid.","Page large reads: loop over row windows of a few thousand rows.","For exports, operate on the file rather than reading every cell through this tool."],"tags":["rust","excel","validation","limits","range-size","xlsx","resource-guard"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}