{"record":{"id":"3495be97a6e5f96d","repo":"golang/go","slug":"mismatched-id","errorCode":null,"errorMessage":"mismatched ID","messagePattern":"mismatched ID","errorType":"exception","errorClass":"entryNotFoundError","httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/cache/cache.go","lineNumber":232,"sourceCode":"\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\n\tfor i < len(esize) && esize[i] == ' ' {\n\t\ti++\n\t}\n\tsize, err := strconv.ParseInt(string(esize[i:]), 10, 64)\n\tif err != nil {\n\t\treturn missing(fmt.Errorf(\"parsing size: %v\", err))\n\t} else if size < 0 {\n\t\treturn missing(errors.New(\"negative size\"))\n\t}\n\ti = 0\n\tfor i < len(etime) && etime[i] == ' ' {\n\t\ti++\n\t}","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/cache/cache.go#L214-L250","documentation":"The action ID hex-decoded from the entry file header does not match the ActionID that was requested. The entry file is stored at a path derived from the ActionID hash, and the header embeds the same ID for verification. A mismatch means the file at this path contains an entry for a different action — an internal inconsistency.","triggerScenarios":"DiskCache.get(id) successfully decodes the hex action ID from entry[3:3+hexSize], compares it against the requested id parameter (a [HashSize]byte), and they differ.","commonSituations":"SHA-256 collision (astronomically unlikely but theoretically possible); filesystem or storage-level corruption that swapped file contents between paths; cache directory manually tampered with or partially restored from backup; GOCACHEPROG returning wrong entry data.","solutions":["Run go clean -cache to rebuild from scratch","Verify the cache directory hasn't been manually modified or partially restored","Check for filesystem or storage-level corruption with fsck and SMART diagnostics","If using GOCACHEPROG, verify the program returns correct data for the requested ActionID"],"exampleFix":"// before: ID mismatch in cache entry\n// $ go build ./... # fails with 'cache entry not found: mismatched ID'\n\n// after: clean cache\n// $ go clean -cache && go build ./...","handlingStrategy":"try-catch","validationCode":"// No practical pre-validation for a hash mismatch — it indicates\n// existing corruption. The best prevention is cache hygiene.\n// Periodically verify cache health:\nfunc periodicCacheClean() {\n    exec.Command(\"go\", \"clean\", \"-cache\").Run()\n}","typeGuard":"func isMismatchedID(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"mismatched ID\")\n}","tryCatchPattern":"// entry, err := cache.Get(id)\n// if err != nil {\n//     // Mismatched ID is extremely rare — indicates deep corruption.\n//     // Rebuild and consider running go clean -cache.\n//     output = rebuild()\n// }","preventionTips":["Never manually edit or move files inside the GOCACHE directory","Don't restore cache from backups — let it rebuild naturally","If using GOCACHEPROG, verify the program returns entries for the correct ActionID","Run go clean -cache if you suspect any tampering"],"tags":["go","build-cache","corruption","disk-cache","integrity"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}