JuliusBrussee/caveman · error
cachebench: corpus input exceeds byte limit
Error message
cachebench: corpus input exceeds byte limit %d
What it means
The io.LimitedReader wrapped around the corpus input was exhausted (limited.N <= 0), meaning the corpus stream is larger than limits.MaxInputBytes. The read is bounded deliberately so oversized inputs cannot consume unbounded memory.
Solutions
- Raise CorpusLimits.MaxInputBytes if the corpus is legitimately larger
- Split or truncate the corpus before reading
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at cacheengine/cachebench/corpus.go:158 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/f71c5a87bf0754c9.
Report an issue: GitHub.
Appendix: source
Thrown at cacheengine/cachebench/corpus.go:158
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)
}
if err != nil {
return AgentCorpus{}, err
}
if len(rows) == 0 {
return AgentCorpus{}, errors.New("cachebench: empty corpus")
}
return AgentCorpus{Metadata: metadata, Rows: rows, SHA256: corpusDigest(rows), Bytes: corpusRetainedBytes(rows)}, nil
}
func normalizedCorpusLimits(limits CorpusLimits) (CorpusLimits, error) {
defaults := DefaultCorpusLimits()
if limits.MaxRows <= 0 {
limits.MaxRows = defaults.MaxRows
}
if limits.MaxSessions <= 0 {
limits.MaxSessions = defaults.MaxSessions
}View on GitHub (pinned to 766dce6b13)