{"record":{"id":"51000b28a2462662","repo":"JuliusBrussee/caveman","slug":"message-exceeds-byte-limit","errorCode":null,"errorMessage":"message exceeds byte limit","messagePattern":"message exceeds byte limit","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/corpus.go","lineNumber":380,"sourceCode":"\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\")\n\t}\n\treturn nil\n}\n\nfunc appendCorpusRow(rows *[]CorpusRow, sessions map[string]bool, retainedBytes *int64, row CorpusRow, limits CorpusLimits) error {\n\tif len(*rows) >= limits.MaxRows {\n\t\treturn fmt.Errorf(\"row limit %d exceeded\", limits.MaxRows)\n\t}\n\tif !sessions[row.SessionID] {\n\t\tif len(sessions) >= limits.MaxSessions {\n\t\t\treturn fmt.Errorf(\"session limit %d exceeded\", limits.MaxSessions)\n\t\t}\n\t\tsessions[row.SessionID] = true\n\t}\n\trowBytes := corpusRowRetainedBytes(row)","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/cachebench/corpus.go#L362-L398","documentation":"Sentinel from validateCorpusMessage: the computed messageBytes total (content + role + tool_call_id + name + tool-call id/type/name) exceeds limits.MaxMessageBytes. This is the aggregate per-message budget check after individual field validation passed.","triggerScenarios":"Thrown at cacheengine/cachebench/corpus.go:380 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Shrink the message (drop tool calls or shorten content) so its aggregate byte size fits MaxMessageBytes","Increase MaxMessageBytes in CorpusLimits when the corpus legitimately carries larger messages","Split one huge message into multiple smaller turns where semantically acceptable"],"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"}