{"record":{"id":"6a2552a51c20dde3","repo":"qax-os/excelize","slug":"coordinates-length-must-be-4","errorCode":null,"errorMessage":"coordinates length must be 4","messagePattern":"coordinates length must be 4","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":43,"sourceCode":"\t// boolean type XML attribute.\n\tErrAttrValBool = errors.New(\"unexpected child of attrValBool\")\n\t// ErrCellCharsLength defined the error message for receiving a cell\n\t// characters length that exceeds the limit.\n\tErrCellCharsLength = fmt.Errorf(\"cell value must be 0-%d characters\", TotalCellChars)\n\t// ErrCellStyles defined the error message on cell styles exceeds the limit.\n\tErrCellStyles = fmt.Errorf(\"the cell styles exceeds the %d limit\", MaxCellStyles)\n\t// ErrChartTitle defined the error message on both formula and rich text for\n\t// chart title.\n\tErrChartTitle = errors.New(\"cannot set both 'Formula' and 'Paragraph' for chart title\")\n\t// ErrColumnNumber defined the error message on receive an invalid column\n\t// number.\n\tErrColumnNumber = fmt.Errorf(\"the column number must be greater than or equal to %d and less than or equal to %d\", MinColumns, MaxColumns)\n\t// ErrColumnWidth defined the error message on receive an invalid column\n\t// width.\n\tErrColumnWidth = fmt.Errorf(\"the width of the column must be less than or equal to %d characters\", MaxColumnWidth)\n\t// ErrCoordinates defined the error message on invalid coordinates tuples\n\t// length.\n\tErrCoordinates = errors.New(\"coordinates length must be 4\")\n\t// ErrCustomNumFmt defined the error message on receive the empty custom\n\t// number format.\n\tErrCustomNumFmt = errors.New(\"custom number format can not be empty\")\n\t// ErrDataValidationFormulaLength defined the error message for receiving a\n\t// data validation formula length that exceeds the limit.\n\tErrDataValidationFormulaLength = fmt.Errorf(\"data validation must be 0-%d characters\", MaxFieldLength)\n\t// ErrDataValidationRange defined the error message on set decimal range\n\t// exceeds limit.\n\tErrDataValidationRange = errors.New(\"data validation range exceeds limit\")\n\t// ErrDefinedNameDuplicate defined the error message on the same name\n\t// already exists on the scope.\n\tErrDefinedNameDuplicate = errors.New(\"the same name already exists on the scope\")\n\t// ErrDefinedNameScope defined the error message on not found defined name\n\t// in the given scope.\n\tErrDefinedNameScope = errors.New(\"no defined name on the scope\")\n\t// ErrExistsSheet defined the error message on given sheet already exists.\n\tErrExistsSheet = errors.New(\"the same name sheet already exists\")\n\t// ErrExistsTableName defined the error message on given table already","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L25-L61","documentation":"ErrCoordinates is returned when a coordinates tuple does not contain exactly 4 integers. Functions like sortCoordinates and coordinatesToRangeRef expect [col1,row1,col2,row2] defining a rectangular range; any other length cannot form a range reference. It is a fast input-shape check.","triggerScenarios":"Calling coordinatesToRangeRef or sortCoordinates with slices of length 0, 2, 3, 5+ instead of exactly 4; passing a two-cell pair [col1,row1,col2,row2] misremembered as two separate args or as [x1,y1,x2,y2] of wrong arity.","commonSituations":"Building ranges from user input or CLI flags where some values were dropped; appending coordinates in a loop but forgetting the end cell; confusing cell coordinates (2 ints) with range coordinates (4 ints).","solutions":["Ensure the slice has exactly 4 elements: [col1, row1, col2, row2]","Use CoordinatesToCellName twice and join with \":\" if you only have two individual cells","Add a length check (len(c) == 4) before calling and produce a domain-specific error","Remember coordinates are 1-based row and 0-based/1-based per API docs — verify ordering col,row,col,row"],"exampleFix":"// before\nref, err := f.coordinatesToRangeRef([]int{1, 1, 5}) // ErrCoordinates\n// after\nref, err := f.coordinatesToRangeRef([]int{1, 1, 5, 10}) // \"B1:F10\"-style range","handlingStrategy":"type-guard","validationCode":"func validRange(c []int) bool { return len(c) == 4 }","typeGuard":"func isRangeCoordinates(c []int) bool {\n    return len(c) == 4 && c[0] >= 1 && c[2] >= 1\n}","tryCatchPattern":null,"preventionTips":["Always build range slices as [col1,row1,col2,row2]","Use a constructor/helper instead of literal slices at call sites","Distinguish 2-int cell coordinates from 4-int range coordinates in your types"],"tags":["coordinates","range","input-validation"],"backgroundTag":"invalid-array-length","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}