{"record":{"id":"f94fc10955b6103e","repo":"golang/go","slug":"entry-file-incomplete","errorCode":null,"errorMessage":"entry file incomplete","messagePattern":"entry file incomplete","errorType":"exception","errorClass":"entryNotFoundError","httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/cache/cache.go","lineNumber":219,"sourceCode":"func (c *DiskCache) get(id ActionID) (Entry, error) {\n\tmissing := func(reason error) (Entry, error) {\n\t\treturn Entry{}, &entryNotFoundError{Err: reason}\n\t}\n\tf, err := os.Open(c.fileName(id, \"a\"))\n\tif err != nil {\n\t\treturn missing(err)\n\t}\n\tdefer f.Close()\n\tentry := make([]byte, entrySize+1) // +1 to detect whether f is too long\n\tif n, err := io.ReadFull(f, entry); n > entrySize {\n\t\treturn missing(errors.New(\"too long\"))\n\t} else if err != io.ErrUnexpectedEOF {\n\t\tif err == io.EOF {\n\t\t\treturn missing(errors.New(\"file is empty\"))\n\t\t}\n\t\treturn missing(err)\n\t} else if n < entrySize {\n\t\treturn missing(errors.New(\"entry file incomplete\"))\n\t}\n\tif entry[0] != 'v' || entry[1] != '1' || entry[2] != ' ' || entry[3+hexSize] != ' ' || entry[3+hexSize+1+hexSize] != ' ' || entry[3+hexSize+1+hexSize+1+20] != ' ' || entry[entrySize-1] != '\\n' {\n\t\treturn missing(errors.New(\"invalid header\"))\n\t}\n\teid, entry := entry[3:3+hexSize], entry[3+hexSize:]\n\teout, entry := entry[1:1+hexSize], entry[1+hexSize:]\n\tesize, entry := entry[1:1+20], entry[1+20:]\n\tetime, entry := entry[1:1+20], entry[1+20:]\n\tvar buf [HashSize]byte\n\tif _, err := hex.Decode(buf[:], eid); err != nil {\n\t\treturn missing(fmt.Errorf(\"decoding ID: %v\", err))\n\t} else if buf != id {\n\t\treturn missing(errors.New(\"mismatched ID\"))\n\t}\n\tif _, err := hex.Decode(buf[:], eout); err != nil {\n\t\treturn missing(fmt.Errorf(\"decoding output ID: %v\", err))\n\t}\n\ti := 0","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/cache/cache.go#L201-L237","documentation":"The entry file was partially read — io.ReadFull returned ErrUnexpectedEOF with fewer than entrySize bytes. The file exists and has some content (1 to entrySize-1 bytes) but was truncated before reaching the minimum valid entry size. This is distinct from the empty-file case: there is data, just not enough.","triggerScenarios":"DiskCache.get(id) reads the entry file and io.ReadFull returns ErrUnexpectedEOF with 0 < n < entrySize. The read started successfully but hit EOF before filling the minimum entrySize-byte buffer.","commonSituations":"Power loss or kill -9 during a cache write truncated the file; filesystem ran out of space partway through the write; disk sector corruption truncated the file; external tool (backup sync, antivirus) partially copied or quarantined the file.","solutions":["Run go clean -cache to remove truncated entries","Check disk space on the GOCACHE partition (df -h)","Ensure stable system conditions during builds — avoid hard kills during compilation","Verify no external tool (backup, sync, antivirus) is modifying cache files"],"exampleFix":"// before: truncated cache entries from interrupted builds\n// $ go build ./... # fails with 'cache entry not found: entry file incomplete'\n\n// after: clean cache\n// $ go clean -cache && go build ./...","handlingStrategy":"try-catch","validationCode":"// Verify cache integrity before a critical build by attempting\n// to read and validate a known-good entry.\nfunc verifyCacheEntry(cache cache.Cache, id cache.ActionID) bool {\n    _, err := cache.Get(id)\n    return err == nil // any error (including truncated) returns false\n}","typeGuard":"func isIncompleteEntry(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"entry file incomplete\")\n}","tryCatchPattern":"// Same pattern as all cache get errors:\n// entry, err := cache.Get(id)\n// if err != nil {\n//     // Truncated entry — treat as miss, rebuild\n//     output = rebuild()\n// }","preventionTips":["Avoid interrupting builds with SIGKILL — use SIGINT (Ctrl+C) for graceful shutdown","Ensure sufficient disk space to prevent partial writes","Don't run multiple go builds writing to the same GOCACHE simultaneously on different machines via NFS","Run go clean -cache if you suspect corruption from an interrupted build"],"tags":["go","build-cache","corruption","disk-cache","truncation"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}