JuliusBrussee/caveman · error

cachebench: invalid corpus metadata

Error message

cachebench: invalid corpus metadata

What it means

Guard at the top of ReadAgentCorpus (cacheengine/cachebench/corpus.go:140): the caller-supplied CorpusMetadata failed validateCorpusMetadata before any parsing started. This is a metadata validation sentinel, so the fault is in the metadata struct passed by the caller (e.g. missing/blank name or other invalid fields), not in the input stream.

Solutions

  1. Inspect the CorpusMetadata value passed to ReadAgentCorpus and fill in required fields such as the corpus name before calling
  2. Check the error from validateCorpusMetadata if wrapped, to identify the specific metadata field at fault
  3. Add a unit test constructing metadata with each invalid field to pin down the failing constraint
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cacheengine/cachebench/corpus.go:140 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18). Data as JSON: /api/errors/2aa4f6270669dfdf. Report an issue: GitHub.

Appendix: source

Thrown at cacheengine/cachebench/corpus.go:140

	SessionID    string          `json:"session_id"`
	Model        string          `json:"model"`
	Input        json.RawMessage `json:"input"`
	OutputLength int             `json:"output_length"`
	PreGap       float64         `json:"pre_gap"`
}

type hfRowWire struct {
	RowIndex int            `json:"row_idx"`
	Row      lmcacheRowWire `json:"row"`
}

// ReadAgentCorpus imports supported JSONL formats under explicit limits.
func ReadAgentCorpus(reader io.Reader, format string, metadata CorpusMetadata, limits CorpusLimits) (AgentCorpus, error) {
	if reader == nil {
		return AgentCorpus{}, errors.New("cachebench: nil corpus reader")
	}
	if !validBoundedText(metadata.Name, 512, false) || !validBoundedText(metadata.License, 256, true) || !validBoundedText(metadata.Revision, 512, true) {
		return AgentCorpus{}, errors.New("cachebench: invalid corpus metadata")
	}
	var err error
	limits, err = normalizedCorpusLimits(limits)
	if err != nil {
		return AgentCorpus{}, err
	}
	limited := &io.LimitedReader{R: reader, N: limits.MaxInputBytes + 1}
	var rows []CorpusRow
	switch format {
	case CorpusFormatLMCacheJSONL:
		rows, err = readLMCacheJSONL(limited, limits)
	case CorpusFormatHFRows:
		rows, err = readHFRows(limited, limits)
	default:
		return AgentCorpus{}, fmt.Errorf("cachebench: unsupported corpus format %q", format)
	}
	if limited.N <= 0 {
		return AgentCorpus{}, fmt.Errorf("cachebench: corpus input exceeds byte limit %d", limits.MaxInputBytes)

View on GitHub (pinned to 766dce6b13)