{"record":{"id":"2aa4f6270669dfdf","repo":"JuliusBrussee/caveman","slug":"cachebench-invalid-corpus-metadata","errorCode":null,"errorMessage":"cachebench: invalid corpus metadata","messagePattern":"cachebench: invalid corpus metadata","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/corpus.go","lineNumber":140,"sourceCode":"\tSessionID    string          `json:\"session_id\"`\n\tModel        string          `json:\"model\"`\n\tInput        json.RawMessage `json:\"input\"`\n\tOutputLength int             `json:\"output_length\"`\n\tPreGap       float64         `json:\"pre_gap\"`\n}\n\ntype hfRowWire struct {\n\tRowIndex int            `json:\"row_idx\"`\n\tRow      lmcacheRowWire `json:\"row\"`\n}\n\n// ReadAgentCorpus imports supported JSONL formats under explicit limits.\nfunc ReadAgentCorpus(reader io.Reader, format string, metadata CorpusMetadata, limits CorpusLimits) (AgentCorpus, error) {\n\tif reader == nil {\n\t\treturn AgentCorpus{}, errors.New(\"cachebench: nil corpus reader\")\n\t}\n\tif !validBoundedText(metadata.Name, 512, false) || !validBoundedText(metadata.License, 256, true) || !validBoundedText(metadata.Revision, 512, true) {\n\t\treturn AgentCorpus{}, errors.New(\"cachebench: invalid corpus metadata\")\n\t}\n\tvar err error\n\tlimits, err = normalizedCorpusLimits(limits)\n\tif err != nil {\n\t\treturn AgentCorpus{}, err\n\t}\n\tlimited := &io.LimitedReader{R: reader, N: limits.MaxInputBytes + 1}\n\tvar rows []CorpusRow\n\tswitch format {\n\tcase CorpusFormatLMCacheJSONL:\n\t\trows, err = readLMCacheJSONL(limited, limits)\n\tcase CorpusFormatHFRows:\n\t\trows, err = readHFRows(limited, limits)\n\tdefault:\n\t\treturn AgentCorpus{}, fmt.Errorf(\"cachebench: unsupported corpus format %q\", format)\n\t}\n\tif limited.N <= 0 {\n\t\treturn AgentCorpus{}, fmt.Errorf(\"cachebench: corpus input exceeds byte limit %d\", limits.MaxInputBytes)","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/cachebench/corpus.go#L122-L158","documentation":"Guard at the top of ReadAgentCorpus (cacheengine/cachebench/corpus.go:140): the caller-supplied CorpusMetadata failed validateCorpusMetadata before any parsing started. This is a metadata validation sentinel, so the fault is in the metadata struct passed by the caller (e.g. missing/blank name or other invalid fields), not in the input stream.","triggerScenarios":"Thrown at cacheengine/cachebench/corpus.go:140 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the CorpusMetadata value passed to ReadAgentCorpus and fill in required fields such as the corpus name before calling","Check the error from validateCorpusMetadata if wrapped, to identify the specific metadata field at fault","Add a unit test constructing metadata with each invalid field to pin down the failing constraint"],"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"}