{"record":{"id":"46bbab12fe5fe4d6","repo":"chenhg5/cc-connect","slug":"empty-batch-item","errorCode":null,"errorMessage":"empty batch item","messagePattern":"empty batch item","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/engine.go","lineNumber":15654,"sourceCode":"\t\tif (r < '0' || r > '9') && r != '-' {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc parseDeleteBatchIndices(spec string, max int) ([]int, error) {\n\tparts := strings.Split(spec, \",\")\n\tif len(parts) == 0 {\n\t\treturn nil, fmt.Errorf(\"empty batch spec\")\n\t}\n\tseen := make(map[int]struct{}, len(parts))\n\tindices := make([]int, 0, len(parts))\n\n\tfor _, part := range parts {\n\t\tpart = strings.TrimSpace(part)\n\t\tif part == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"empty batch item\")\n\t\t}\n\n\t\tif strings.Contains(part, \"-\") {\n\t\t\tbounds := strings.Split(part, \"-\")\n\t\t\tif len(bounds) != 2 || bounds[0] == \"\" || bounds[1] == \"\" {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid range %q\", part)\n\t\t\t}\n\t\t\tstart, err := strconv.Atoi(bounds[0])\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tend, err := strconv.Atoi(bounds[1])\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif start < 1 || end < 1 || start > end || end > max {\n\t\t\t\treturn nil, fmt.Errorf(\"range %q out of bounds\", part)\n\t\t\t}","sourceCodeStart":15636,"sourceCodeEnd":15672,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/engine.go#L15636-L15672","documentation":"parseDeleteBatchIndices returns this error when an individual comma-separated item in the batch spec is empty after trimming whitespace, e.g. a trailing comma or double comma. The parser requires every item to be a non-empty index or range.","triggerScenarios":"Passing a spec with empty items such as '1,,3', '1,3,', or ',2' to parseDeleteBatchIndices.","commonSituations":"Users hand-typing index lists with stray commas; scripts concatenating lists where an element is blank.","solutions":["Remove stray/extra commas from the spec, e.g. use '1,3' not '1,,3,'","Sanitize the input before parsing: split, drop empty parts or reject early","Trim the whole spec and collapse repeated commas before calling the parser"],"exampleFix":"// before\nparseDeleteBatchIndices(\"1,,3\", 20)\n// after\nparseDeleteBatchIndices(\"1,3\", 20)","handlingStrategy":"validation","validationCode":"parts := strings.Split(spec, \",\")\nfor _, p := range parts {\n    if strings.TrimSpace(p) == \"\" {\n        return errors.New(\"spec contains an empty item: \" + spec)\n    }\n}","typeGuard":null,"tryCatchPattern":"_, err := parseDeleteBatchIndices(spec, max)\nif err != nil {\n    reply(\"invalid list %q: %v\", spec, err)\n}","preventionTips":["Reject or drop empty items before parsing instead of letting the parser fail","Avoid building specs by naive string concatenation; append with a join that skips blanks","Normalize user input: trim ends and collapse ',,' occurrences"],"tags":["parsing","validation","batch-delete"],"backgroundTag":"invalid-argument-format","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}