{"record":{"id":"901a7c3f4c3675f0","repo":"JuliusBrussee/caveman","slug":"cachebench-session-q-request-d-w","errorCode":null,"errorMessage":"cachebench: session %q request %d: %w","messagePattern":"cachebench: session %q request (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/corpus.go","lineNumber":644,"sourceCode":"\t}\n\treturn prefix, nil\n}\n\nfunc buildCorpusTrace(provider ProviderConfig, corpus AgentCorpus, counter *corpusTokenCounter) (Trace, error) {\n\tstarted := time.Date(2026, 8, 10, 0, 0, 0, 0, time.UTC)\n\trequests := make([]TraceRequest, 0, len(corpus.Rows))\n\trequestNumber := map[string]int{}\n\telapsed := map[string]time.Duration{}\n\tepochVersion := map[string]int{}\n\tstableIdentity := map[string]string{}\n\tfor _, row := range corpus.Rows {\n\t\trequestNumber[row.SessionID]++\n\t\tif requestNumber[row.SessionID] > 1 {\n\t\t\telapsed[row.SessionID] += time.Duration(row.PreGap * float64(time.Second))\n\t\t}\n\t\tbody, err := corpusProviderBody(provider, row.Input)\n\t\tif err != nil {\n\t\t\treturn Trace{}, fmt.Errorf(\"cachebench: session %q request %d: %w\", row.SessionID, requestNumber[row.SessionID], err)\n\t\t}\n\t\tprefix, err := corpusPrefix(row.Input, counter)\n\t\tif err != nil {\n\t\t\treturn Trace{}, err\n\t\t}\n\t\tstableCount := 0\n\t\tfor _, message := range row.Input {\n\t\t\tif message.Role != \"system\" && message.Role != \"developer\" {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tstableCount++\n\t\t}\n\t\tidentity, identityErr := corpusStableIdentity(row.Input, stableCount)\n\t\tif identityErr != nil {\n\t\t\treturn Trace{}, identityErr\n\t\t}\n\t\tif epochVersion[row.SessionID] == 0 {\n\t\t\tepochVersion[row.SessionID] = 1","sourceCodeStart":626,"sourceCodeEnd":662,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/cacheengine/cachebench/corpus.go#L626-L662","documentation":"While replaying a corpus as a trace, building the provider-specific request body for a row failed; the error records the session ID and the 1-based request number within that session, wrapping the body-construction error from corpusProviderBody.","triggerScenarios":"Calling the trace-building path over a corpus when corpusProviderBody(provider, row.Input) returns an error — most commonly the unsupported-provider error, or content conversion failures for the selected provider (e.g. non-string content that provider's body builder cannot encode).","commonSituations":"Provider config with a misspelled Provider value; an anthropic/bedrock/gemini replay of messages whose content is array-form, since contentText only accepts string or null.","solutions":["Check the wrapped error: if it is 'unsupported corpus provider', fix ProviderConfig.Provider.","Ensure message content is a plain JSON string (or null) for providers whose body builders call contentText.","Re-emit the corpus with string content before replaying to anthropic/bedrock/gemini."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"switch provider.Provider {\ncase \"openai\", \"anthropic\", \"bedrock\", \"gemini\":\ndefault:\n\treturn fmt.Errorf(\"unsupported corpus provider %q\", provider.Provider)\n}\n// plus verify all messages have string-or-null content for non-openai providers:\nfor _, row := range corpus.Rows {\n\tfor _, m := range row.Input {\n\t\tif _, err := contentText(m.Content); err != nil {\n\t\t\treturn fmt.Errorf(\"row content not convertible: %w\", err)\n\t\t}\n\t}\n}","typeGuard":null,"tryCatchPattern":"trace, err := BuildTrace(corpus, provider)\nif err != nil {\n\tif strings.Contains(err.Error(), \"unsupported corpus provider\") {\n\t\t// fix provider config and re-run\n\t}\n\treturn err\n}","preventionTips":["Validate ProviderConfig against the allow-list at config load.","Export corpora with string-only content for cross-provider replay.","Unit-test body building for every provider you configure."],"tags":["go","cachebench","provider","replay"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}