{"record":{"id":"a4ea1aab600bfed5","repo":"JuliusBrussee/caveman","slug":"duplicate-or-invalid-json","errorCode":null,"errorMessage":"duplicate or invalid JSON","messagePattern":"duplicate or invalid JSON","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/corpus.go","lineNumber":302,"sourceCode":"\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\")\n\t}\n\treturn nil\n}\n\nfunc validateCorpusWire(wire lmcacheRowWire, index int, limits CorpusLimits) (CorpusRow, error) {\n\tif !validBoundedText(wire.SessionID, 2048, false) || !validBoundedText(wire.Model, 512, false) {\n\t\treturn CorpusRow{}, errors.New(\"session_id and model required\")\n\t}\n\tif wire.OutputLength < 0 || math.IsNaN(wire.PreGap) || math.IsInf(wire.PreGap, 0) || wire.PreGap < 0 || wire.PreGap > maxCorpusGapSeconds {\n\t\treturn CorpusRow{}, fmt.Errorf(\"output_length must be non-negative and pre_gap must be within 0..%d seconds\", maxCorpusGapSeconds)","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/cachebench/corpus.go#L284-L320","documentation":"Generic sentinel from decodeOneJSON: the raw row bytes failed validUniqueJSONObject, meaning the blob is not a valid JSON object or contains duplicate top-level (or nested, per the checker) keys. Callers wrap it with context (e.g. 'decode Hugging Face row: ...'), so the fault is in the individual row's raw bytes, not the enclosing stream.","triggerScenarios":"Thrown at cacheengine/cachebench/corpus.go:302 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Validate the offending row blob independently (e.g. jq) to see whether it is malformed or has duplicate keys","Remove duplicate JSON keys — later keys silently overriding earlier ones are rejected here by design","Regenerate the row from the source dataset instead of patching it by hand"],"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"}