plandex-ai/plandex · error
start line is less than 1: %d
Error message
start line is less than 1: %d
What it means
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.
Source
Thrown at app/shared/streamed_change.go:71
} else {
endLine, err = ExtractLineNumberWithPrefix(streamedChangeSection.EndLineString, prefix)
if err != nil {
log.Printf("Error extracting end line number: %v\n", err)
return 0, 0, fmt.Errorf("error extracting end line number: %v", err)
}
}
log.Printf("StartLine: %d, EndLine: %d\n", startLine, endLine)
if startLine > endLine {
log.Printf("Start line is greater than end line: %d > %d\n", startLine, endLine)
return 0, 0, fmt.Errorf("start line is greater than end line: %d > %d", startLine, endLine)
}
if startLine < 1 {
log.Printf("Start line is less than 1: %d\n", startLine)
return 0, 0, fmt.Errorf("start line is less than 1: %d", startLine)
}
return startLine, endLine, nil
}
func ExtractLineNumber(line string) (int, error) {
return ExtractLineNumberWithPrefix(line, "pdx-")
}
func ExtractLineNumberWithPrefix(line, prefix string) (int, error) {
// Split the line at the first space to isolate the line number
parts := strings.SplitN(line, " ", 2)
// Remove the colon from the line number part
lineNumberStr := strings.TrimSuffix(parts[0], ":")
lineNumberStr = strings.TrimPrefix(lineNumberStr, prefix)
if lineNumberStr == "" {
return 0, fmt.Errorf("no line number found")View on GitHub (pinned to e2d772072e)
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
Example fix
// before
start, end, err := GetLinesWithPrefix(section, prefix) // start=0 -> error
// after
if start, err = ExtractLineNumberWithPrefix(section.StartLineString, prefix); err == nil && start == 0 { start = 1 }
start, end, err = GetLinesWithPrefix(section, prefix) Defensive patterns
Strategy: validation
Validate before calling
func startLineAtLeastOne(section shared.StreamedChangeSection, prefix string) error {
s, err := shared.ExtractLineNumberWithPrefix(section.StartLineString, prefix)
if err != nil { return err }
if s < 1 { return fmt.Errorf("start line %d < 1", s) }
return nil
} Try / catch
start, end, err := GetLinesWithPrefix(section, prefix)
if err != nil {
if strings.Contains(err.Error(), "less than 1") {
return fmt.Errorf("1-based line numbers required; got 0-based marker %q", section.StartLineString)
}
return err
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: Model emitting 0-based line numbers while the library expects 1-based; empty section lines parsed as line 0.
Related errors
- invalid line number for first line: %d
- invalid line numbers: %d-%d
- start line is greater than end line: %d > %d
- invalid context index: %s
- no context found with name: %s
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/ee709cc567c76169.
Report an issue: GitHub.