{"record":{"id":"cad197ab2fa2ba31","repo":"plandex-ai/plandex","slug":"invalid-line-number-v","errorCode":null,"errorMessage":"invalid line number: %v","messagePattern":"invalid line number: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"app/shared/streamed_change.go","lineNumber":95,"sourceCode":"func 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\")\n\t}\n\n\t// Convert the line number part to an integer\n\tlineNumber, err := strconv.Atoi(lineNumberStr)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"invalid line number: %v\", err)\n\t}\n\n\treturn lineNumber, nil\n}\n","sourceCodeStart":77,"sourceCodeEnd":100,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/shared/streamed_change.go#L77-L100","documentation":"ExtractLineNumberWithPrefix parses a line number from a text chunk in a streamed response (e.g. `42: some code`). After locating the prefix, it converts the numeric portion with strconv.Atoi; if that conversion fails (the text after the prefix is not a valid integer), it returns this wrapped error. This indicates the streamed content did not match the expected `NNN: text` format.","triggerScenarios":"Calling ExtractLineNumberWithPrefix (directly or via ExtractLineNumber or GetLinesWithPrefix) on a string whose prefix, after stripping, is non-numeric — e.g. an empty string, `abc: foo`, `1.5: x`, or output from a model that changed its line-prefix format.","commonSituations":"Model output format drift where the assistant stops emitting `N: ` prefixes; parsing truncated or partial streamed chunks where the number got split across chunks; parsing human-written text (headings like `Note: ...`) that coincidentally contains a colon.","solutions":["Inspect the actual input string at the call site and confirm it matches the expected `<digits>: <text>` format before parsing","Fix the upstream stream so chunks are not split mid-token (join chunks before extracting line numbers)","Handle the error gracefully by skipping chunks without a parseable line number instead of propagating it","Check for model/provider changes that alter the line-prefix convention and update the extraction regex accordingly"],"exampleFix":"// before\nlineNumber, err := ExtractLineNumberWithPrefix(chunk)\nif err != nil {\n    return err\n}\n// after\nlineNumber, err := ExtractLineNumberWithPrefix(chunk)\nif err != nil {\n    log.Printf(\"skipping chunk without line number: %v\", err)\n    continue\n}","handlingStrategy":"validation","validationCode":"re := regexp.MustCompile(`^(\\d+)\\s*:`)\nif !re.MatchString(chunk) {\n    // skip or handle chunk without a line-number prefix\n}","typeGuard":"func hasLineNumberPrefix(s string) bool {\n    i := strings.Index(s, \":\")\n    if i <= 0 { return false }\n    _, err := strconv.Atoi(strings.TrimSpace(s[:i]))\n    return err == nil\n}","tryCatchPattern":null,"preventionTips":["Join full streamed chunks before extracting line numbers","Add a format test covering the model's line-prefix output","Log skipped chunks instead of failing the whole stream"],"tags":["parsing","streaming","format"],"backgroundTag":"line-number-parse-failed","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"}