golang/go · error · entryNotFoundError

GOCACHEPROG didn't populate DiskPath on get hit

Error message

GOCACHEPROG didn't populate DiskPath on get hit

What it means

The GOCACHEPROG program returned a cache hit response (Miss=false) but left the DiskPath field empty. A hit response must include the on-disk path to the output file so the Go toolchain can read it. An empty DiskPath on a reported hit violates the cacheprog protocol contract — the program claims to have the data but doesn't say where.

Source

Thrown at src/cmd/go/internal/cache/prog.go:290

		Command:  cacheprog.CmdGet,
		ActionID: a[:],
	})
	if err != nil {
		return Entry{}, err // TODO(bradfitz): or entryNotFoundError? Audit callers.
	}
	if res.Miss {
		return Entry{}, &entryNotFoundError{}
	}
	e := Entry{
		Size: res.Size,
	}
	if res.Time != nil {
		e.Time = *res.Time
	} else {
		e.Time = time.Now()
	}
	if res.DiskPath == "" {
		return Entry{}, &entryNotFoundError{errors.New("GOCACHEPROG didn't populate DiskPath on get hit")}
	}
	if copy(e.OutputID[:], res.OutputID) != len(res.OutputID) {
		return Entry{}, &entryNotFoundError{errors.New("incomplete ProgResponse OutputID")}
	}
	c.noteOutputFile(e.OutputID, res.DiskPath)
	return e, nil
}

func (c *ProgCache) noteOutputFile(o OutputID, diskPath string) {
	c.mu.Lock()
	defer c.mu.Unlock()
	c.outputFile[o] = diskPath
}

func (c *ProgCache) OutputFile(o OutputID) string {
	c.mu.Lock()
	defer c.mu.Unlock()
	return c.outputFile[o]

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Report or fix the bug in the GOCACHEPROG program — it must set DiskPath on every hit response
  2. Update the GOCACHEPROG program to a version compatible with your Go release's cacheprog protocol
  3. Check the cacheprog protocol documentation (cmd/internal/cacheprog) the program should implement
  4. Temporarily unset GOCACHEPROG to use the default disk cache while debugging
  5. Review the program's Get handler to ensure it always sets DiskPath when Miss is false

Example fix

// before: GOCACHEPROG program omits DiskPath on hits
// (in the cache program's Get handler)
// func handleGet(req *Request) *Response {
//     return &Response{Miss: false}  // missing DiskPath!
// }

// after: always set DiskPath when reporting a hit
// func handleGet(req *Request) *Response {
//     path, ok := store.Lookup(req.ActionID)
//     if !ok {
//         return &Response{Miss: true}
//     }
//     return &Response{Miss: false, DiskPath: path, OutputID: outID, Size: size}
// }
Defensive patterns

Strategy: validation

Validate before calling

// Validate that the GOCACHEPROG program correctly implements the protocol
// by running a test get operation and checking the response fields.
// This requires implementing a small test harness that speaks the cacheprog
// JSON protocol over stdin/stdout.
//
// At minimum, verify the program's documentation or changelog confirms
// it sets DiskPath on hit responses for your Go version.

Type guard

func isMissingDiskPath(err error) bool {
    return err != nil && strings.Contains(err.Error(), "didn't populate DiskPath")
}

Try / catch

// entry, err := progCache.Get(id)
// if err != nil {
//     if isMissingDiskPath(err) {
//         // The cache program has a protocol bug.
//         // Fall back to disk cache.
//         os.Unsetenv("GOCACHEPROG")
//         entry, err = diskCache.Get(id)
//     }
//     if err != nil {
//         // Rebuild from source
//         output = rebuild()
//     }
// }

Prevention

When it happens

Trigger: ProgCache.Get() receives a cacheprog.Response with res.Miss == false and res.DiskPath == ''. The code checks this condition right after confirming it's not a miss.

Common situations: Bug in the GOCACHEPROG program — it reports a hit but forgets to populate DiskPath; the program's storage backend had an issue locating the cached output path; protocol version mismatch between Go and the cache program; the program uses a non-standard storage model that doesn't map to on-disk paths.

Related errors


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