{"record":{"id":"36692505d62166b5","repo":"JuliusBrussee/caveman","slug":"content-must-decode","errorCode":null,"errorMessage":"content must decode","messagePattern":"content must decode","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/corpus.go","lineNumber":365,"sourceCode":"\tswitch message.Role {\n\tcase \"system\", \"developer\", \"user\", \"assistant\", \"tool\":\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported role %q\", message.Role)\n\t}\n\tif !validBoundedText(message.ToolCallID, 2048, true) || !validBoundedText(message.Name, 512, true) {\n\t\treturn errors.New(\"invalid message identity\")\n\t}\n\tif len(message.Content) == 0 && len(message.ToolCalls) == 0 {\n\t\treturn errors.New(\"content or tool_calls required\")\n\t}\n\tif len(message.Content) > limits.MaxMessageBytes || (len(message.Content) > 0 && !json.Valid(message.Content)) {\n\t\treturn errors.New(\"content invalid or exceeds limit\")\n\t}\n\tmessageBytes := len(message.Content) + len(message.Role) + len(message.ToolCallID) + len(message.Name)\n\tif len(message.Content) > 0 {\n\t\tvar content any\n\t\tif err := json.Unmarshal(message.Content, &content); err != nil {\n\t\t\treturn errors.New(\"content must decode\")\n\t\t}\n\t\tif content != nil {\n\t\t\tif _, ok := content.(string); !ok {\n\t\t\t\treturn errors.New(\"content must be string or null\")\n\t\t\t}\n\t\t}\n\t}\n\tfor _, call := range message.ToolCalls {\n\t\tif call.Type != \"function\" || !validBoundedText(call.ID, 2048, false) || !validBoundedText(call.Function.Name, 512, false) || !validUniqueJSONObject([]byte(call.Function.Arguments)) {\n\t\t\treturn errors.New(\"tool call requires function type, id, function name, and JSON arguments\")\n\t\t}\n\t\tmessageBytes += len(call.ID) + len(call.Type) + len(call.Function.Name) + len(call.Function.Arguments)\n\t}\n\tif messageBytes > limits.MaxMessageBytes {\n\t\treturn errors.New(\"message exceeds byte limit\")\n\t}\n\tif message.Role == \"tool\" && message.ToolCallID == \"\" {\n\t\treturn errors.New(\"tool message requires tool_call_id\")","sourceCodeStart":347,"sourceCodeEnd":383,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/cachebench/corpus.go#L347-L383","documentation":"Sentinel from validateCorpusMessage: json.Unmarshal of the non-empty, json.Valid-passing content bytes into an 'any' failed. This catches content that is valid JSON at a byte level but still not decodable into a plain value (e.g. multiple values or decoder-level errors).","triggerScenarios":"Thrown at cacheengine/cachebench/corpus.go:365 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-encode the content as a single clean JSON value (typically a quoted string)","Remove concatenated or truncated fragments inside the content field","Validate content with a strict single-document decode in your export pipeline"],"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"}