{"record":{"id":"f4a58ac912f02be4","repo":"JuliusBrussee/caveman","slug":"cachebench-invalid-hugging-face-rows-key","errorCode":null,"errorMessage":"cachebench: invalid Hugging Face rows key","messagePattern":"cachebench: invalid Hugging Face rows key","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/corpus.go","lineNumber":245,"sourceCode":"func readHFRows(reader io.Reader, limits CorpusLimits) ([]CorpusRow, error) {\n\tdecoder := json.NewDecoder(reader)\n\tfirst, err := decoder.Token()\n\tif err != nil || first != json.Delim('{') {\n\t\treturn nil, errors.New(\"cachebench: Hugging Face rows root must be object\")\n\t}\n\trows := make([]CorpusRow, 0)\n\tsessions := map[string]bool{}\n\tvar retainedBytes int64\n\tfoundRows := false\n\trootKeys := map[string]bool{}\n\tfor decoder.More() {\n\t\tkeyToken, err := decoder.Token()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"cachebench: read Hugging Face rows key: %w\", err)\n\t\t}\n\t\tkey, ok := keyToken.(string)\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"cachebench: invalid Hugging Face rows key\")\n\t\t}\n\t\tif rootKeys[key] {\n\t\t\treturn nil, fmt.Errorf(\"cachebench: duplicate Hugging Face field %q\", key)\n\t\t}\n\t\trootKeys[key] = true\n\t\tif key != \"rows\" {\n\t\t\tvar ignored json.RawMessage\n\t\t\tif err := decoder.Decode(&ignored); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"cachebench: skip Hugging Face field %q: %w\", key, err)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tfoundRows = true\n\t\tstart, err := decoder.Token()\n\t\tif err != nil || start != json.Delim('[') {\n\t\t\treturn nil, errors.New(\"cachebench: Hugging Face rows field must be array\")\n\t\t}\n\t\tfor decoder.More() {","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/cachebench/corpus.go#L227-L263","documentation":"Raised in readHFRows when a key token inside the root object does not decode to a Go string. This is a structural guard: JSON object keys are always strings, so a non-string key token means the stream is malformed or truncated at that position.","triggerScenarios":"Thrown at cacheengine/cachebench/corpus.go:245 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Validate the document with a strict JSON parser or jq before feeding it to readHFRows","Regenerate the export from the Hugging Face dataset viewer rather than hand-editing it","Check for truncation caused by hitting MaxInputBytes during download"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}