golang/go · error · entryNotFoundError

mismatched ID

Error message

mismatched ID

What it means

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.

Source

Thrown at src/cmd/go/internal/cache/cache.go:232

		if err == io.EOF {
			return missing(errors.New("file is empty"))
		}
		return missing(err)
	} else if n < entrySize {
		return missing(errors.New("entry file incomplete"))
	}
	if 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' {
		return missing(errors.New("invalid header"))
	}
	eid, entry := entry[3:3+hexSize], entry[3+hexSize:]
	eout, entry := entry[1:1+hexSize], entry[1+hexSize:]
	esize, entry := entry[1:1+20], entry[1+20:]
	etime, entry := entry[1:1+20], entry[1+20:]
	var buf [HashSize]byte
	if _, err := hex.Decode(buf[:], eid); err != nil {
		return missing(fmt.Errorf("decoding ID: %v", err))
	} else if buf != id {
		return missing(errors.New("mismatched ID"))
	}
	if _, err := hex.Decode(buf[:], eout); err != nil {
		return missing(fmt.Errorf("decoding output ID: %v", err))
	}
	i := 0
	for i < len(esize) && esize[i] == ' ' {
		i++
	}
	size, err := strconv.ParseInt(string(esize[i:]), 10, 64)
	if err != nil {
		return missing(fmt.Errorf("parsing size: %v", err))
	} else if size < 0 {
		return missing(errors.New("negative size"))
	}
	i = 0
	for i < len(etime) && etime[i] == ' ' {
		i++
	}

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Run go clean -cache to rebuild from scratch
  2. Verify the cache directory hasn't been manually modified or partially restored
  3. Check for filesystem or storage-level corruption with fsck and SMART diagnostics
  4. If using GOCACHEPROG, verify the program returns correct data for the requested ActionID

Example fix

// before: ID mismatch in cache entry
// $ go build ./... # fails with 'cache entry not found: mismatched ID'

// after: clean cache
// $ go clean -cache && go build ./...
Defensive patterns

Strategy: try-catch

Validate before calling

// No practical pre-validation for a hash mismatch — it indicates
// existing corruption. The best prevention is cache hygiene.
// Periodically verify cache health:
func periodicCacheClean() {
    exec.Command("go", "clean", "-cache").Run()
}

Type guard

func isMismatchedID(err error) bool {
    return err != nil && strings.Contains(err.Error(), "mismatched ID")
}

Try / catch

// entry, err := cache.Get(id)
// if err != nil {
//     // Mismatched ID is extremely rare — indicates deep corruption.
//     // Rebuild and consider running go clean -cache.
//     output = rebuild()
// }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/3495be97a6e5f96d. Report an issue: GitHub.