{"record":{"id":"bcc8db712bea9642","repo":"chenhg5/cc-connect","slug":"range-q-out-of-bounds","errorCode":null,"errorMessage":"range %q out of bounds","messagePattern":"range %q out of bounds","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/engine.go","lineNumber":15671,"sourceCode":"\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)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tidx, err := strconv.Atoi(part)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif idx < 1 || idx > max {\n\t\t\treturn nil, fmt.Errorf(\"index %d out of bounds\", idx)\n\t\t}","sourceCodeStart":15653,"sourceCodeEnd":15689,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/engine.go#L15653-L15689","documentation":"Batch-item range parser rejected a range like \"5-3\" or \"12-40\" where max is lower: start/end are not both >=1, start > end, or end exceeds the number of available items. The message echoes the offending range expression.","triggerScenarios":"Passing a range whose start or end exceeds the item count (e.g. '1-50' when max=20), a zero or negative bound ('0-5'), or an inverted range ('7-3').","commonSituations":"User guesses the number of history items and over-ranges; stale UI listing fewer items than the spec assumes after items were deleted.","solutions":["Re-check the number of items (e.g. via the history listing) and use ranges within 1..max","Fix inverted ranges so start <= end, e.g. '3-7' not '7-3'","Ensure bounds are >= 1; index numbering starts at 1","Refresh the list before composing the delete spec so indices match current items"],"exampleFix":"// before\nparseDeleteBatchIndices(\"1-50\", 20) // max is 20\n// after\nparseDeleteBatchIndices(\"1-20\", 20)","handlingStrategy":"validation","validationCode":"if max <= 0 {\n    return errors.New(\"nothing to delete\")\n}\nif start < 1 || end > max || start > end {\n    return fmt.Errorf(\"range must be within 1-%d\", max)\n}","typeGuard":null,"tryCatchPattern":"if _, err := parseDeleteBatchIndices(spec, count); err != nil {\n    reply(\"out of range: %v (valid: 1-%d)\", err, count)\n}","preventionTips":["Fetch the current item count immediately before building the delete spec","Display the valid 1..N range in the listing so users copy correct bounds","Refresh the list after every delete so stale indices are never reused"],"tags":["parsing","range","out-of-bounds"],"backgroundTag":"value-out-of-range","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"}