{"record":{"id":"ee5b889562af1831","repo":"JuliusBrussee/caveman","slug":"cachebench-trailing-json-after-hugging-face-rows","errorCode":null,"errorMessage":"cachebench: trailing JSON after Hugging Face rows object","messagePattern":"cachebench: trailing JSON after Hugging Face rows object","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/corpus.go","lineNumber":292,"sourceCode":"\t\t\t}\n\t\t\trow, err := validateCorpusWire(wire.Row, wire.RowIndex, limits)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"cachebench: Hugging Face row %d: %w\", wire.RowIndex, err)\n\t\t\t}\n\t\t\tif err := appendCorpusRow(&rows, sessions, &retainedBytes, row, limits); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"cachebench: Hugging Face row %d: %w\", wire.RowIndex, err)\n\t\t\t}\n\t\t}\n\t\tif end, err := decoder.Token(); err != nil || end != json.Delim(']') {\n\t\t\treturn nil, errors.New(\"cachebench: malformed Hugging Face rows array\")\n\t\t}\n\t}\n\tif end, err := decoder.Token(); err != nil || end != json.Delim('}') {\n\t\treturn nil, errors.New(\"cachebench: malformed Hugging Face rows object\")\n\t}\n\tvar trailing any\n\tif err := decoder.Decode(&trailing); err != io.EOF {\n\t\treturn nil, errors.New(\"cachebench: trailing JSON after Hugging Face rows object\")\n\t}\n\tif !foundRows {\n\t\treturn nil, errors.New(\"cachebench: Hugging Face response has no rows field\")\n\t}\n\treturn rows, nil\n}\n\nfunc decodeOneJSON(raw []byte, destination any) error {\n\tif !validUniqueJSONObject(raw) {\n\t\treturn errors.New(\"duplicate or invalid JSON\")\n\t}\n\tdecoder := json.NewDecoder(bytes.NewReader(raw))\n\tif err := decoder.Decode(destination); err != nil {\n\t\treturn err\n\t}\n\tvar trailing any\n\tif err := decoder.Decode(&trailing); err != io.EOF {\n\t\treturn errors.New(\"trailing JSON\")","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/cachebench/corpus.go#L274-L310","documentation":"Raised in readHFRows when decoding after the root object's '}' yields anything other than io.EOF. The parser demands exactly one JSON document; trailing bytes (second object, stray newline-delimited records, appended log lines) are rejected.","triggerScenarios":"Thrown at cacheengine/cachebench/corpus.go:292 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Feed only a single HF rows JSON object to the HFRows reader","If you have newline-delimited records, switch to the LMCache JSONL format instead","Trim trailing whitespace-only junk, but note any non-whitespace trailing content is a hard error"],"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"}