JuliusBrussee/caveman · error

cachebench: duplicate Hugging Face field

Error message

cachebench: duplicate Hugging Face field %q

What it means

Strict-parsing guard in readHFRows: the same top-level key appeared more than once in the Hugging Face rows JSON object. Duplicated keys can change meaning depending on decode order, so the input JSON is rejected.

Solutions

  1. Regenerate the JSON export with a serializer that emits unique keys
  2. Deduplicate object keys before feeding the file to ReadAgentCorpus
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cacheengine/cachebench/corpus.go:248 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/0b51773540c9bcca. Report an issue: GitHub.

Appendix: source

Thrown at cacheengine/cachebench/corpus.go:248

	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)
		}
		rootKeys[key] = true
		if key != "rows" {
			var ignored json.RawMessage
			if err := decoder.Decode(&ignored); err != nil {
				return nil, fmt.Errorf("cachebench: skip Hugging Face field %q: %w", key, err)
			}
			continue
		}
		foundRows = true
		start, err := decoder.Token()
		if err != nil || start != json.Delim('[') {
			return nil, errors.New("cachebench: Hugging Face rows field must be array")
		}
		for decoder.More() {
			var raw json.RawMessage
			if err := decoder.Decode(&raw); err != nil {
				return nil, fmt.Errorf("cachebench: decode Hugging Face row: %w", err)

View on GitHub (pinned to 766dce6b13)