{"record":{"id":"a9eb981522755338","repo":"chenhg5/cc-connect","slug":"invalid-range-q","errorCode":null,"errorMessage":"invalid range %q","messagePattern":"invalid range %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/engine.go","lineNumber":15660,"sourceCode":"\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}\n\t\t\tfor idx := start; idx <= end; idx++ {\n\t\t\t\tif _, ok := seen[idx]; ok {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tseen[idx] = struct{}{}\n\t\t\t\tindices = append(indices, idx)","sourceCodeStart":15642,"sourceCodeEnd":15678,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/engine.go#L15642-L15678","documentation":"This error is returned when a batch spec item containing a dash is not a well-formed N-M range. The item is split on '-' and must yield exactly two non-empty bounds; anything else (e.g. '5-', '-3', '1-2-3') is rejected.","triggerScenarios":"Passing a malformed range like '5-' (missing end), '-3' (missing start), or '1-2-3' (more than one dash) inside the comma-separated spec.","commonSituations":"Typo when typing a delete range; confusion between negative numbers and ranges; copy-paste errors from docs.","solutions":["Write the range as start-end with both bounds present, e.g. '3-7'","Ensure ranges appear only once per item (no extra dashes)","Validate the range format in the command handler before invoking the parser"],"exampleFix":"// before\nparseDeleteBatchIndices(\"5-\", 20)\n// after\nparseDeleteBatchIndices(\"5-10\", 20)","handlingStrategy":"validation","validationCode":"for _, item := range strings.Split(spec, \",\") {\n    if strings.Contains(item, \"-\") {\n        b := strings.Split(item, \"-\")\n        if len(b) != 2 || b[0] == \"\" || b[1] == \"\" {\n            return fmt.Errorf(\"range must be start-end, got %q\", item)\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"if _, err := parseDeleteBatchIndices(spec, max); err != nil {\n    reply(\"bad range in %q: %v (format: start-end)\", spec, err)\n}","preventionTips":["Show the expected range syntax (N-M) in command help text","Validate each item with a regex like ^\\d+(-\\d+)?$ before calling the parser","Avoid negative-number ambiguity by forbidding '-' not surrounded by digits"],"tags":["parsing","range","validation"],"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"}