golang/go · error · entryNotFoundError
negative timestamp
Error message
negative timestamp
What it means
The timestamp field in the cache entry header parsed as a valid integer but is negative. The timestamp represents nanoseconds since Unix epoch and must be non-negative. The entry format space-pads the timestamp to 20 bytes; after stripping spaces and parsing, a negative value indicates corruption in the timestamp portion.
Source
Thrown at src/cmd/go/internal/cache/cache.go:255
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++
}
tm, err := strconv.ParseInt(string(etime[i:]), 10, 64)
if err != nil {
return missing(fmt.Errorf("parsing timestamp: %v", err))
} else if tm < 0 {
return missing(errors.New("negative timestamp"))
}
c.markUsed(c.fileName(id, "a"))
return Entry{buf, size, time.Unix(0, tm)}, nil
}
// GetFile looks up the action ID in the cache and returns
// the name of the corresponding data file.
func GetFile(c Cache, id ActionID) (file string, entry Entry, err error) {
entry, err = c.Get(id)
if err != nil {
return "", Entry{}, err
}
file = c.OutputFile(entry.OutputID)
info, err := os.Stat(file)
if err != nil {
return "", Entry{}, &entryNotFoundError{Err: err}View on GitHub (pinned to b6b368adc5)
Solutions
- Run go clean -cache to purge corrupt entries
- Run hardware diagnostics (memtest, disk SMART) if corruption recurs
- Ensure consistent Go version across all builds sharing the cache
- Check filesystem integrity
Example fix
// before: corrupt timestamp field in cache entry // $ go build ./... # fails with 'cache entry not found: negative timestamp' // after: clean cache // $ go clean -cache && go build ./...
Defensive patterns
Strategy: try-catch
Validate before calling
// No pre-check can predict timestamp field corruption. // Same hardware reliability and cache hygiene practices apply.
Type guard
func isNegativeTimestamp(err error) bool {
return err != nil && strings.Contains(err.Error(), "negative timestamp")
} Try / catch
// entry, err := cache.Get(id)
// if err != nil {
// // Negative timestamp — corrupt timestamp field. Rebuild.
// output = rebuild()
// } Prevention
- Run go clean -cache after Go version changes
- Ensure reliable hardware (RAM, disk) to prevent bit-level corruption
- Keep cache on local reliable storage
- Avoid shared/network cache directories that may introduce corruption
When it happens
Trigger: DiskCache.get(id) parses the 20-byte space-padded timestamp field (etime) with strconv.ParseInt(s, 10, 64) after stripping leading spaces. The parse succeeds but tm < 0.
Common situations: Byte-level corruption in the timestamp field region of the entry file; storage errors affecting specific sectors; cache format incompatibility from mixing Go versions.
Related errors
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/431a2186e4d6259d.
Report an issue: GitHub.