{"record":{"id":"1b61a070e604ada4","repo":"golang/go","slug":"preprocessed-profile-entry-missing-weight","errorCode":null,"errorMessage":"preprocessed profile entry missing weight","messagePattern":"preprocessed profile entry missing weight","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/internal/pgo/deserialize.go","lineNumber":65,"sourceCode":"\n\tfor scanner.Scan() {\n\t\treadStr := scanner.Text()\n\n\t\tcallerName := readStr\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 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,","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/internal/pgo/deserialize.go#L47-L83","documentation":"Thrown when deserializing a preprocessed PGO profile and the scanner reaches clean EOF (scanner.Err() is nil) before the third line of an edge entry — the weight/call-site-offset line — is found. Each edge entry must have three lines: caller name, callee name, then a combined \"offset weight\" line; this error means the entry is truncated after the callee.","triggerScenarios":"scanner.Scan() returns false with scanner.Err() == nil on the third Scan(), indicating a clean end-of-input. The profile file ends after the callee name line but before the weight line, so the entry is incomplete.","commonSituations":"A preprocessed profile file that was truncated mid-write, or one that was manually constructed with only two lines per entry instead of three. Also seen when a different serialization format version produced entries with fewer fields.","solutions":["Regenerate the preprocessed profile so every edge entry has all three required lines: caller, callee, and \"offset weight\".","Check that the file ends with a complete final entry (no partial trailing lines).","Validate the file format against the serializer's output to ensure version compatibility."],"exampleFix":"// Data fix: ensure each entry is 3 lines. Correct format:\n// example.com/pkg.Func\n// example.com/pkg.Callee\n// 42 1000\n// (callsite-offset weight)","handlingStrategy":"validation","validationCode":"// Check that the file has a complete set of 3-line entries:\nfunc checkProfileCompleteness(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    if len(lines) % 3 != 0 {\n        return fmt.Errorf(\"incomplete entry: %d lines is not divisible by 3\", len(lines))\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure the serialization step flushes and closes the file properly so no trailing entry is truncated.","Validate the preprocessed profile has a line count divisible by 3 before deserialization.","Regenerate profiles with the same Go toolchain version that will consume them."],"tags":["pgo","deserialization","truncated-data","go-compiler-internal"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}