{"record":{"id":"dfe93496ed875dc1","repo":"larksuite/cli","slug":"empty-range-dfe934","errorCode":null,"errorMessage":"empty range","messagePattern":"empty range","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/sheets/lark_sheet_write_cells.go","lineNumber":1140,"sourceCode":"// get_sheet_structure, outside the scope of pure local parsing. The error\n// wording is load-bearing: +styles-put surfaces it verbatim\n// (\"cell_styles range %q: %v\").\n//\n// The sheet part is cut by scanSheetQualifier, the same grammar the selector\n// rewrite uses, so both agree with the front-end ref lexer on what counts as a\n// separator. Splitting on the first \"!\" instead would miss the full-width\n// separator entirely and would cut a quoted name in half at its own \"!\".\nfunc parseCellRange(s string) (cellRange, error) {\n\tout := cellRange{}\n\t// Trim before cutting the qualifier, not after: otherwise \" sheet1!B2\"\n\t// carries the leading space into it and into every range rendered from it.\n\tbody := strings.TrimSpace(s)\n\tif _, end, ok := scanSheetQualifier(body); ok {\n\t\tout.sheetQualifier = body[:end]\n\t\tbody = strings.TrimSpace(body[end:])\n\t}\n\tif body == \"\" {\n\t\treturn out, fmt.Errorf(\"empty range\") //nolint:forbidigo // intermediate error; callers wrap it into a typed --range/--source-range validation error\n\t}\n\tparts := strings.SplitN(body, \":\", 2)\n\tout.start = strings.TrimSpace(parts[0])\n\tstartCol, startRow, ok := splitCellRef(out.start)\n\tout.col, out.row = startCol, startRow\n\tif len(parts) == 1 {\n\t\t// single cell, e.g. \"A1\"\n\t\tif !ok {\n\t\t\treturn cellRange{}, fmt.Errorf(\"invalid cell ref %q\", parts[0]) //nolint:forbidigo // intermediate error; callers wrap it into a typed --range/--source-range validation error\n\t\t}\n\t\tout.rows, out.cols, out.anchored = 1, 1, true\n\t\treturn out, nil\n\t}\n\tendCol, endRow, okEnd := splitCellRef(parts[1])\n\tif !ok || !okEnd {\n\t\treturn cellRange{}, fmt.Errorf(\"unsupported range form %q (need rectangular A1:B2)\", body) //nolint:forbidigo // intermediate error; callers wrap it into a typed --range/--source-range validation error\n\t}\n\tif endRow < startRow || endCol < startCol {","sourceCodeStart":1122,"sourceCodeEnd":1158,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/sheets/lark_sheet_write_cells.go#L1122-L1158","documentation":"parseCellRange parses --range/--source-range strings into a cellRange. After stripping an optional 'Sheet!' qualifier, if nothing remains to parse it reports 'empty range'. This is an intermediate error that callers wrap into a typed --range/--source-range validation error.","triggerScenarios":"Passing an empty string, only whitespace, or a value consisting solely of a sheet qualifier like 'Sheet1!' (nothing after the '!') to a flag parsed by parseCellRange (used by checkCellsMatchRange, expandAnchorRange, rangeDimensions).","commonSituations":"Shell variable expansion producing an empty value (unset env var), users typing only the sheet name with trailing '!', or copy-pasting a range that got trimmed away.","solutions":["Provide a non-empty cell range such as 'A1' or 'A1:B2' for the flag.","If using a sheet qualifier, include the cell range after it, e.g. 'Sheet1!A1:B2'.","Check shell variables/expansions that feed the flag so they are not empty.","Consult --help/schema for the expected --range/--source-range format."],"exampleFix":"// before\n--range \"\"\n--range \"Sheet1!\"\n// after\n--range \"Sheet1!A1:B2\"","handlingStrategy":"validation","validationCode":"r := strings.TrimSpace(rangeFlag)\nif r == \"\" || strings.HasSuffix(r, \"!\") {\n\treturn fmt.Errorf(\"--range must include a cell range, e.g. Sheet1!A1:B2\")\n}","typeGuard":"func nonEmptyRange(s string) bool { return strings.TrimSpace(strings.TrimSuffix(strings.TrimSpace(s), \"!\")) != \"\" }","tryCatchPattern":null,"preventionTips":["Check flag values are non-empty before invoking commands, especially from shell variables.","A sheet qualifier alone is not a range — always append cell coordinates."],"tags":["validation","sheets","range-parsing","cli"],"backgroundTag":"invalid-range-format","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}