plandex-ai/plandex · error

error extracting start line number: %v

Error message

error extracting start line number: %v

What it means

GetLinesWithPrefix resolves a streamed change section's line range. When StartLineString is non-empty it must be parsed via ExtractLineNumberWithPrefix; this error wraps that parse failure, meaning the start-line string is not a valid prefixed line number (e.g. missing prefix, non-numeric).

Source

Thrown at app/shared/streamed_change.go:41

func (streamedChangeSection StreamedChangeSection) GetLines() (int, int, error) {
	return streamedChangeSection.GetLinesWithPrefix("pdx-")
}

func (streamedChangeSection StreamedChangeSection) GetLinesWithPrefix(prefix string) (int, int, error) {
	var startLine, endLine int
	var err error

	if streamedChangeSection.StartLineString == "" {
		log.Printf("StartLineString is empty\n")
		// spew.Dump(streamedChangeSection)
		startLine = streamedChangeSection.StartLine
	} else {
		startLine, err = ExtractLineNumberWithPrefix(streamedChangeSection.StartLineString, prefix)

		if err != nil {
			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)
		}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Check the wrapped %v error ("no line number found" vs "invalid line number") to see which sub-parse failed
  2. Ensure the `prefix` argument matches the prefix used when the section was generated
  3. Validate the streamed section's StartLineString before calling GetLines (see validationCode)
  4. Re-request the streamed change if the output was truncated/malformed

Example fix

// before
start, end, err := GetLinesWithPrefix(section, "  ")
// after
if section.StartLineString == "" { return nil, errors.New("missing start line") }
if _, err := ExtractLineNumberWithPrefix(section.StartLineString, "  "); err != nil { return nil, fmt.Errorf("bad start line %q: %w", section.StartLineString, err) }
start, end, err := GetLinesWithPrefix(section, "  ")
Defensive patterns

Strategy: validation

Validate before calling

func validStartLine(section shared.StreamedChangeSection, prefix string) bool {
    if section.StartLineString == "" { return true } // resolved from StartLine
    _, err := shared.ExtractLineNumberWithPrefix(section.StartLineString, prefix)
    return err == nil
}

Try / catch

start, end, err := GetLinesWithPrefix(section, prefix)
if err != nil {
    if strings.Contains(err.Error(), "start line number") {
        return fmt.Errorf("malformed streamed section start %q: %w", section.StartLineString, err)
    }
    return err
}

Prevention

When it happens

Trigger: GetLines / GetLinesWithPrefix receiving a StreamedChangeSection whose StartLineString fails ExtractLineNumberWithPrefix (bad prefix match, no numeric part, or Atoi failure propagated through).

Common situations: Streaming LLM output truncated or malformed mid-section so the start line marker is incomplete; using a different line prefix than the one passed in; section parsed from a different code-fence style.

Related errors


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/49fe2cb622ec3e76. Report an issue: GitHub.