{"record":{"id":"ee709cc567c76169","repo":"plandex-ai/plandex","slug":"start-line-is-less-than-1-d","errorCode":null,"errorMessage":"start line is less than 1: %d","messagePattern":"start line is less than 1: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/shared/streamed_change.go","lineNumber":71,"sourceCode":"\t} else {\n\t\tendLine, err = ExtractLineNumberWithPrefix(streamedChangeSection.EndLineString, prefix)\n\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Error extracting end line number: %v\\n\", err)\n\t\t\treturn 0, 0, fmt.Errorf(\"error extracting end line number: %v\", err)\n\t\t}\n\t}\n\n\tlog.Printf(\"StartLine: %d, EndLine: %d\\n\", startLine, endLine)\n\n\tif startLine > endLine {\n\t\tlog.Printf(\"Start line is greater than end line: %d > %d\\n\", startLine, endLine)\n\t\treturn 0, 0, fmt.Errorf(\"start line is greater than end line: %d > %d\", startLine, endLine)\n\t}\n\n\tif startLine < 1 {\n\t\tlog.Printf(\"Start line is less than 1: %d\\n\", startLine)\n\t\treturn 0, 0, fmt.Errorf(\"start line is less than 1: %d\", startLine)\n\t}\n\n\treturn startLine, endLine, nil\n}\n\nfunc ExtractLineNumber(line string) (int, error) {\n\treturn ExtractLineNumberWithPrefix(line, \"pdx-\")\n}\n\nfunc ExtractLineNumberWithPrefix(line, prefix string) (int, error) {\n\t// Split the line at the first space to isolate the line number\n\tparts := strings.SplitN(line, \" \", 2)\n\n\t// Remove the colon from the line number part\n\tlineNumberStr := strings.TrimSuffix(parts[0], \":\")\n\tlineNumberStr = strings.TrimPrefix(lineNumberStr, prefix)\n\tif lineNumberStr == \"\" {\n\t\treturn 0, fmt.Errorf(\"no line number found\")","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/shared/streamed_change.go#L53-L89","documentation":"GetLinesWithPrefix enforces 1-based line numbers; a parsed start line of 0 or negative is invalid and rejected with this error. It typically results from parsing a 0, a malformed marker, or a prefix that stripped all digits.","triggerScenarios":"GetLines with StartLineString parsing to < 1 — e.g. marker \"0\", or prefix trimming leaving no/zero digits (often accompanying \"no line number found\" upstream in similar paths).","commonSituations":"Model emitting 0-based line numbers while the library expects 1-based; empty section lines parsed as line 0.","solutions":["Convert any 0-based numbering to 1-based before constructing the section","Ensure the start marker is present and numeric (guard empty StartLineString earlier)","Clamp/validate: if parsed start is 0, treat as 1 or reject before calling GetLines","Re-stream the section if the marker was truncated"],"exampleFix":"// before\nstart, end, err := GetLinesWithPrefix(section, prefix) // start=0 -> error\n// after\nif start, err = ExtractLineNumberWithPrefix(section.StartLineString, prefix); err == nil && start == 0 { start = 1 }\nstart, end, err = GetLinesWithPrefix(section, prefix)","handlingStrategy":"validation","validationCode":"func startLineAtLeastOne(section shared.StreamedChangeSection, prefix string) error {\n    s, err := shared.ExtractLineNumberWithPrefix(section.StartLineString, prefix)\n    if err != nil { return err }\n    if s < 1 { return fmt.Errorf(\"start line %d < 1\", s) }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"start, end, err := GetLinesWithPrefix(section, prefix)\nif err != nil {\n    if strings.Contains(err.Error(), \"less than 1\") {\n        return fmt.Errorf(\"1-based line numbers required; got 0-based marker %q\", section.StartLineString)\n    }\n    return err\n}","preventionTips":["Convert 0-based numbering to 1-based when building sections","Reject or clamp markers parsing to 0 before calling GetLines","Document/enforce 1-based line markers across tooling"],"tags":["go","validation","line-numbers","off-by-one"],"backgroundTag":"invalid-line-range","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}