{"record":{"id":"4cc53af63b761055","repo":"golang/go","slug":"preprocessed-profile-entry-got-v-want-2-fields","errorCode":null,"errorMessage":"preprocessed profile entry got %v want 2 fields","messagePattern":"preprocessed profile entry got (.+?) want 2 fields","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/internal/pgo/deserialize.go","lineNumber":72,"sourceCode":"\t\t\tif err := scanner.Err(); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"error reading preprocessed profile: %w\", err)\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"preprocessed profile entry missing callee\")\n\t\t}\n\t\tcalleeName := scanner.Text()\n\n\t\tif !scanner.Scan() {\n\t\t\tif err := scanner.Err(); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"error reading preprocessed profile: %w\", err)\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"preprocessed profile entry missing weight\")\n\t\t}\n\t\treadStr = scanner.Text()\n\n\t\tsplit := strings.Split(readStr, \" \")\n\n\t\tif len(split) != 2 {\n\t\t\treturn nil, fmt.Errorf(\"preprocessed profile entry got %v want 2 fields\", split)\n\t\t}\n\n\t\tco, err := strconv.Atoi(split[0])\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"preprocessed profile error processing call line: %w\", err)\n\t\t}\n\n\t\tedge := NamedCallEdge{\n\t\t\tCallerName:     callerName,\n\t\t\tCalleeName:     calleeName,\n\t\t\tCallSiteOffset: co,\n\t\t}\n\n\t\tweight, err := strconv.ParseInt(split[1], 10, 64)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"preprocessed profile error processing call weight: %w\", err)\n\t\t}\n","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/internal/pgo/deserialize.go#L54-L90","documentation":"Thrown when the third line of a preprocessed PGO profile edge entry (the weight line) does not split into exactly 2 space-separated fields. The deserializer expects \"<call-site-offset> <weight>\" but strings.Split produced a different count — meaning the line has extra spaces, missing a field, or has a different delimiter.","triggerScenarios":"strings.Split(readStr, \" \") on the weight line yields a slice whose length is not 2. This happens when the line has zero spaces (single field), multiple spaces (3+ fields after split), leading/trailing spaces, or uses a different separator like a tab.","commonSituations":"Profile serialized by a tool that used tab separators instead of spaces, or a tool that emitted extra metadata fields on the weight line. Also occurs if the file was reformatted or had whitespace stripped/added by an editor or version-control system.","solutions":["Regenerate the profile with the matching Go toolchain to ensure the exact \"offset weight\" space-separated format.","Inspect the raw weight line bytes for tabs, multiple spaces, or missing fields and fix the serialization.","Ensure no editor or CI step reflows whitespace in the profile file."],"exampleFix":"// The weight line must be exactly: \"<int> <int>\"\n// Before (broken): \"42  1000\" (double space -> 3 fields after split)\n// After (fixed):  \"42 1000\"","handlingStrategy":"validation","validationCode":"// Pre-validate that every third line has exactly 2 space-separated fields:\nfunc validateWeightLines(path string) error {\n    data, err := os.ReadFile(path)\n    if err != nil { return err }\n    lines := strings.Split(strings.TrimRight(string(data), \"\\n\"), \"\\n\")\n    for i := 2; i < len(lines); i += 3 {\n        fields := strings.Split(lines[i], \" \")\n        if len(fields) != 2 {\n            return fmt.Errorf(\"line %d: expected 2 fields, got %d\", i+1, len(fields))\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never edit preprocessed profile files manually — regenerate from source.","Ensure the serializer uses a single space between offset and weight.","Validate the weight-line format before deserialization."],"tags":["pgo","deserialization","format-mismatch","go-compiler-internal"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}