{"record":{"id":"6470de1a57733230","repo":"JuliusBrussee/caveman","slug":"corpus-provider-conversion-supports-string-or-null","errorCode":null,"errorMessage":"corpus provider conversion supports string or null content","messagePattern":"corpus provider conversion supports string or null content","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/corpus.go","lineNumber":734,"sourceCode":"\t\treturn anthropicCorpusBody(provider.Model, messages)\n\tcase \"bedrock\":\n\t\treturn bedrockCorpusBody(messages)\n\tcase \"gemini\":\n\t\treturn geminiCorpusBody(messages)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported corpus provider %q\", provider.Provider)\n\t}\n}\n\nfunc contentText(content json.RawMessage) (string, error) {\n\tif len(content) == 0 || bytes.Equal(bytes.TrimSpace(content), []byte(\"null\")) {\n\t\treturn \"\", nil\n\t}\n\tvar text string\n\tif err := json.Unmarshal(content, &text); err == nil {\n\t\treturn text, nil\n\t}\n\treturn \"\", errors.New(\"corpus provider conversion supports string or null content\")\n}\n\nfunc anthropicCorpusBody(model string, messages []CorpusMessage) ([]byte, error) {\n\tvar system []string\n\tconverted := make([]any, 0, len(messages))\n\tfor _, message := range messages {\n\t\ttext, err := contentText(message.Content)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tswitch message.Role {\n\t\tcase \"system\", \"developer\":\n\t\t\tif text != \"\" {\n\t\t\t\tsystem = append(system, text)\n\t\t\t}\n\t\tcase \"assistant\":\n\t\t\tblocks := make([]any, 0, len(message.ToolCalls)+1)\n\t\t\tif text != \"\" {","sourceCodeStart":716,"sourceCodeEnd":752,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/cachebench/corpus.go#L716-L752","documentation":"Sentinel from contentText during corpus-to-provider body conversion: the message's raw content bytes are non-null and do not unmarshal into a plain string. The provider converters accept only string or null content (the shapes validateCorpusMessage enforces), so non-string content here means the row bypassed or drifted from that validation.","triggerScenarios":"Thrown at cacheengine/cachebench/corpus.go:734 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Normalize corpus content to a JSON string or null during corpus import","Ensure rows always pass validateCorpusWire/validateCorpusMessage before conversion","Serialize structured content blocks into their JSON string form for the corpus format"],"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"}