{"record":{"id":"9b0fcf6cb093b446","repo":"larksuite/cli","slug":"invalid-cell-ref-q-9b0fcf","errorCode":null,"errorMessage":"invalid cell ref %q","messagePattern":"invalid cell ref %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/sheets/lark_sheet_write_cells.go","lineNumber":1149,"sourceCode":"\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 {\n\t\treturn cellRange{}, fmt.Errorf(\"end %q must be at or after start %q\", parts[1], parts[0]) //nolint:forbidigo // intermediate error; callers wrap it into a typed --range/--source-range validation error\n\t}\n\tout.rows, out.cols = endRow-startRow+1, endCol-startCol+1\n\treturn out, nil\n}\n\nfunc rangeDimensions(rangeStr string) (rows, cols int, err error) {\n\tr, err := parseCellRange(rangeStr)\n\tif err != nil {","sourceCodeStart":1131,"sourceCodeEnd":1167,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/sheets/lark_sheet_write_cells.go#L1131-L1167","documentation":"When parseCellRange receives a single-token range (no colon), it treats it as one cell and validates it with splitCellRef. If the token is not a valid cell reference (column letters followed by a row number, e.g. 'A1'), it throws 'invalid cell ref'. It is an intermediate error later wrapped into a typed --range/--source-range validation error.","triggerScenarios":"Passing a single value without a colon that is not a cell reference, e.g. 'A', '1', 'AA0' (row 0 invalid), '1A', or a whole-column spec like 'A:C' mis-split by other logic.","commonSituations":"Users intending a whole row/column ('A' or '1'), typos in the cell reference, row number 0, or lowercase/odd formats not accepted by the parser.","solutions":["Use a valid cell reference of the form ColumnLetters+RowNumber, e.g. 'A1'.","If a range was intended, supply the full 'A1:B2' form.","Ensure the row number is >= 1; 'A0' is invalid.","Check --help/schema for accepted single-cell and range formats."],"exampleFix":"// before\n--range \"A0\"\n--range \"A\"\n// after\n--range \"A1\"","handlingStrategy":"validation","validationCode":"var cellRe = regexp.MustCompile(`^[A-Za-z]+[1-9][0-9]*$`)\nif !cellRe.MatchString(single) {\n\treturn fmt.Errorf(\"%q is not a cell ref like A1\", single)\n}","typeGuard":"func isCellRef(s string) bool {\n\ti := 0\n\tfor i < len(s) && isLetter(s[i]) { i++ }\n\tif i == 0 || i == len(s) { return false }\n\tfor ; i < len(s); i++ { if !isDigit(s[i]) { return false } }\n\treturn s[len(s)-1] != '0' || rowNumber(s) > 0\n}","tryCatchPattern":null,"preventionTips":["Single-cell ranges must be ColumnLetters+RowNumber with row >= 1 (e.g. A1, not A or A0).","Use explicit bounded ranges instead of whole-column specs."],"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"}