{"record":{"id":"91065d662ed68158","repo":"plandex-ai/plandex","slug":"error-extracting-end-line-number-v","errorCode":null,"errorMessage":"error extracting end line number: %v","messagePattern":"error extracting end line number: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/shared/streamed_change.go","lineNumber":58,"sourceCode":"\t\t\tlog.Printf(\"Error extracting start line number: %v\\n\", err)\n\t\t\treturn 0, 0, fmt.Errorf(\"error extracting start line number: %v\", err)\n\t\t}\n\t}\n\n\tif streamedChangeSection.EndLineString == \"\" {\n\t\tlog.Printf(\"EndLineString is empty\\n\")\n\t\t// spew.Dump(streamedChangeSection)\n\t\tif streamedChangeSection.EndLine > 0 {\n\t\t\tendLine = streamedChangeSection.EndLine\n\t\t} else {\n\t\t\tendLine = startLine\n\t\t}\n\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","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/shared/streamed_change.go#L40-L76","documentation":"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.","triggerScenarios":"GetLines / GetLinesWithPrefix with a StreamedChangeSection whose EndLineString has no numeric part after prefix trimming, or whose numeric part fails Atoi.","commonSituations":"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.","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"],"exampleFix":"// before\nstart, end, err := GetLinesWithPrefix(section, prefix)\n// after\nif _, err := ExtractLineNumberWithPrefix(section.EndLineString, prefix); err != nil { return nil, fmt.Errorf(\"bad end line %q: %w\", section.EndLineString, err) }\nstart, end, err := GetLinesWithPrefix(section, prefix)","handlingStrategy":"validation","validationCode":"func validEndLine(section shared.StreamedChangeSection, prefix string) bool {\n    if section.EndLineString == \"\" { return true }\n    _, err := shared.ExtractLineNumberWithPrefix(section.EndLineString, prefix)\n    return err == nil\n}","typeGuard":null,"tryCatchPattern":"start, end, err := GetLinesWithPrefix(section, prefix)\nif err != nil {\n    if strings.Contains(err.Error(), \"end line number\") {\n        return fmt.Errorf(\"malformed streamed section end %q: %w\", section.EndLineString, err)\n    }\n    return err\n}","preventionTips":["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"],"tags":["go","parsing","line-numbers","streaming"],"backgroundTag":"invalid-line-number-format","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}