plandex-ai/plandex · error
error extracting end line number: %v
Error message
error extracting end line number: %v
What it means
Same as the start-line variant but for the section's EndLineString: ExtractLineNumberWithPrefix failed to parse the end line number, so GetLinesWithPrefix cannot determine the range end and returns this wrapped error.
Source
Thrown at app/shared/streamed_change.go:58
log.Printf("Error extracting start line number: %v\n", err)
return 0, 0, fmt.Errorf("error extracting start line number: %v", err)
}
}
if streamedChangeSection.EndLineString == "" {
log.Printf("EndLineString is empty\n")
// spew.Dump(streamedChangeSection)
if streamedChangeSection.EndLine > 0 {
endLine = streamedChangeSection.EndLine
} else {
endLine = startLine
}
} 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
}
View on GitHub (pinned to e2d772072e)
Solutions
- Read the wrapped error to distinguish missing vs invalid number
- Ensure the end line marker uses the expected prefix plus integer format
- Validate EndLineString before the call (see validationCode)
- Re-stream the section if output was truncated
Example fix
// before
start, end, err := GetLinesWithPrefix(section, prefix)
// after
if _, err := ExtractLineNumberWithPrefix(section.EndLineString, prefix); err != nil { return nil, fmt.Errorf("bad end line %q: %w", section.EndLineString, err) }
start, end, err := GetLinesWithPrefix(section, prefix) Defensive patterns
Strategy: validation
Validate before calling
func validEndLine(section shared.StreamedChangeSection, prefix string) bool {
if section.EndLineString == "" { return true }
_, err := shared.ExtractLineNumberWithPrefix(section.EndLineString, prefix)
return err == nil
} Try / catch
start, end, err := GetLinesWithPrefix(section, prefix)
if err != nil {
if strings.Contains(err.Error(), "end line number") {
return fmt.Errorf("malformed streamed section end %q: %w", section.EndLineString, err)
}
return err
} Prevention
- Guard empty/truncated EndLineString before parsing
- Use one canonical prefix/format for all line markers
- Re-request streamed output when the end marker is missing
When it happens
Trigger: GetLines / GetLinesWithPrefix with a StreamedChangeSection whose EndLineString has no numeric part after prefix trimming, or whose numeric part fails Atoi.
Common situations: Streaming output cut off before the end-line marker completed; end-line formatted without the expected prefix; LLM emitted a range like "10-20" or "EOF" instead of a plain number.
Related errors
- error extracting start line number: %v
- no line number found
- old content does not have a line number prefix for first lin
- error extracting line number from first line: %v
- error extracting line number from last line: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/91065d662ed68158.
Report an issue: GitHub.