JuliusBrussee/caveman · error
cachebench: Hugging Face rows root must be object
Error message
cachebench: Hugging Face rows root must be object
What it means
Raised in readHFRows when the first JSON token from the reader is not the '{' delimiter (or token reading failed). The Hugging Face rows format requires a top-level JSON object; a JSON array, bare value, or malformed leading bytes trigger this.
Solutions
- Ensure the HF rows payload is a top-level object like {"rows": [...]}
- If the input is newline-delimited JSON rows, use CorpusFormatLMCacheJSONL instead of CorpusFormatHFRows
- Strip any BOM or leading garbage before the JSON object
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at cacheengine/cachebench/corpus.go:231 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/18a7b2d7ac02c699.
Report an issue: GitHub.
Appendix: source
Thrown at cacheengine/cachebench/corpus.go:231
row, err := validateCorpusWire(wire, line-1, limits)
if err != nil {
return nil, fmt.Errorf("cachebench: corpus line %d: %w", line, err)
}
if err := appendCorpusRow(&rows, sessions, &retainedBytes, row, limits); err != nil {
return nil, fmt.Errorf("cachebench: corpus line %d: %w", line, err)
}
}
if err := scanner.Err(); err != nil {
return nil, fmt.Errorf("cachebench: read corpus: %w", err)
}
return rows, nil
}
func readHFRows(reader io.Reader, limits CorpusLimits) ([]CorpusRow, error) {
decoder := json.NewDecoder(reader)
first, err := decoder.Token()
if err != nil || first != json.Delim('{') {
return nil, errors.New("cachebench: Hugging Face rows root must be object")
}
rows := make([]CorpusRow, 0)
sessions := map[string]bool{}
var retainedBytes int64
foundRows := false
rootKeys := map[string]bool{}
for decoder.More() {
keyToken, err := decoder.Token()
if err != nil {
return nil, fmt.Errorf("cachebench: read Hugging Face rows key: %w", err)
}
key, ok := keyToken.(string)
if !ok {
return nil, errors.New("cachebench: invalid Hugging Face rows key")
}
if rootKeys[key] {
return nil, fmt.Errorf("cachebench: duplicate Hugging Face field %q", key)
}View on GitHub (pinned to 766dce6b13)