{"record":{"id":"1fe0b410a21a8b8b","repo":"JuliusBrussee/caveman","slug":"cachebench-session-q-row-d-w","errorCode":null,"errorMessage":"cachebench: session %q row %d: %w","messagePattern":"cachebench: session %q row (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/corpus.go","lineNumber":550,"sourceCode":"\tsummary := CorpusSummary{\n\t\tName: corpus.Metadata.Name, License: corpus.Metadata.License, Revision: corpus.Metadata.Revision,\n\t\tSHA256: corpus.SHA256, Sessions: len(sessions), Requests: len(corpus.Rows), Sources: map[string]int{},\n\t\tRetainedBytes: corpus.Bytes,\n\t\tTokenBasis:    counter.Name() + \" estimate over canonical message JSON\",\n\t}\n\tif summary.RetainedBytes == 0 {\n\t\tsummary.RetainedBytes = corpusRetainedBytes(corpus.Rows)\n\t}\n\tturns := make([]int, 0, len(sessions))\n\tfor _, id := range order {\n\t\tsession := sessions[id]\n\t\tturns = append(turns, len(session.Rows))\n\t\tsummary.Sources[corpusSource(id)]++\n\t\tvar previous []PrefixSegment\n\t\tfor index, row := range session.Rows {\n\t\t\tprefix, err := corpusPrefix(row.Input, counter)\n\t\t\tif err != nil {\n\t\t\t\treturn CorpusSummary{}, fmt.Errorf(\"cachebench: session %q row %d: %w\", id, index, err)\n\t\t\t}\n\t\t\teligible := prefixTokens(prefix)\n\t\t\tsummary.EstimatedInputTokens += int64(eligible)\n\t\t\tif index > 0 {\n\t\t\t\treused := commonPrefixTokens(previous, prefix)\n\t\t\t\tsummary.EstimatedReusableTokens += int64(reused)\n\t\t\t\tif reused > 0 {\n\t\t\t\t\tsummary.OpportunityRequestHitRate++\n\t\t\t\t}\n\t\t\t\tif len(prefix) > len(previous) && samePrefix(previous, prefix) {\n\t\t\t\t\tsummary.StrictPrefixExtensions++\n\t\t\t\t} else {\n\t\t\t\t\tsummary.MutatedOrCompactedTransitions++\n\t\t\t\t}\n\t\t\t}\n\t\t\tprevious = prefix\n\t\t}\n\t}","sourceCodeStart":532,"sourceCodeEnd":568,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/cacheengine/cachebench/corpus.go#L532-L568","documentation":"While building the CorpusSummary, converting a row's messages into prefix segments (corpusPrefix) failed for the given session and row index. The wrapper adds session ID and row index so the failing row can be located in the source corpus; the '%w' clause carries the underlying prefix-construction error.","triggerScenarios":"Calling the corpus summarization path over a loaded corpus where corpusPrefix(row.Input, counter) errors for some row — typically content that passed structural validation but cannot be turned into a PrefixSegment (e.g. non-text content shapes unsupported by the tokenizer/segmenter).","commonSituations":"Multimodal or array-form content in messages that the prefix extractor does not handle; corpus produced by a newer exporter whose content format the summarizer version cannot segment.","solutions":["Inspect the wrapped error to identify what corpusPrefix rejected.","Flatten array-form content to plain strings when exporting the corpus.","Re-generate the corpus with the same tool version used for summarization.","Exclude the reported session/row from the corpus if it is not representative."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"for i, row := range session.Rows {\n\tif _, err := corpusPrefix(row.Input, counter); err != nil {\n\t\treturn fmt.Errorf(\"preflight: session %q row %d: %w\", id, i, err)\n\t}\n}","typeGuard":null,"tryCatchPattern":"summary, err := SummarizeCorpus(corpus)\nif err != nil {\n\tvar target *CorpusRow\n\tif strings.Contains(err.Error(), \"cachebench: session\") {\n\t\t// extract session/row from message, fix corpus, retry once\n\t}\n\treturn err\n}","preventionTips":["Keep message content as plain strings so prefix extraction always succeeds.","Use the same tool version to generate and summarize a corpus.","Smoke-test prefix extraction on a sample of rows before full runs."],"tags":["go","cachebench","prefix","corpus"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}