{"record":{"id":"56cba3b5d427d833","repo":"plandex-ai/plandex","slug":"context-body-is-too-large-d-56cba3","errorCode":null,"errorMessage":"context body is too large: %d","messagePattern":"context body is too large: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/db/context_helpers_update.go","lineNumber":111,"sourceCode":"\tif params.ContextsById == nil {\n\t\tcontextsById = make(map[string]*Context)\n\t} else {\n\t\tcontextsById = params.ContextsById\n\t}\n\n\tvar totalContextCount int\n\tvar totalBodySize int64\n\n\tfor _, context := range contextsById {\n\t\ttotalContextCount++\n\t\ttotalBodySize += context.BodySize\n\t}\n\n\tfor id, params := range *req {\n\t\tsize := int64(len(params.Body))\n\n\t\tif size > shared.MaxContextBodySize {\n\t\t\treturn nil, fmt.Errorf(\"context body is too large: %d\", size)\n\t\t}\n\n\t\tif context, ok := contextsById[id]; ok {\n\t\t\ttotalBodySize += size - context.BodySize\n\t\t} else {\n\t\t\ttotalContextCount++\n\t\t\ttotalBodySize += size\n\t\t}\n\t}\n\n\tif totalContextCount > shared.MaxContextCount {\n\t\treturn nil, fmt.Errorf(\"too many contexts to update (found %d, limit is %d)\", totalContextCount, shared.MaxContextCount)\n\t}\n\n\tif totalBodySize > shared.MaxContextBodySize {\n\t\treturn nil, fmt.Errorf(\"total context body size exceeds limit (size %.2f MB, limit %d MB)\", float64(totalBodySize)/1024/1024, int(shared.MaxContextBodySize)/1024/1024)\n\t}\n","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/db/context_helpers_update.go#L93-L129","documentation":"UpdateContexts validates every incoming UpdateContextParams body and returns this error if any single context body exceeds shared.MaxContextBodySize (25MB). This is a per-context cap applied before any database writes.","triggerScenarios":"Calling UpdateContexts with a request map containing one entry whose params.Body length exceeds 25MB (25*1024*1024 bytes).","commonSituations":"Updating a context with the full contents of a large build artifact, video, dataset, or concatenated log file; a client bug uploading an entire directory as one body; user dragging a huge file into the plan context.","solutions":["Reduce the single context body below 25MB (trim, compress, or chunk the content).","Split the file across multiple contexts or reference it by path/URL instead of inlining.","Add client-side size validation before calling UpdateContexts.","Exclude generated/binary files from automatic context syncing."],"exampleFix":"// before\nUpdateContexts(orgId, planId, branch, map[string]*shared.UpdateContextParams{\n    id: {Body: string(giantFileBytes)}, // 60MB\n})\n// after\nif int64(len(giantFileBytes)) > shared.MaxContextBodySize {\n    giantFileBytes = truncateOrSummarize(giantFileBytes)\n}","handlingStrategy":"validation","validationCode":"for id, p := range req {\n    if int64(len(p.Body)) > shared.MaxContextBodySize {\n        return fmt.Errorf(\"context %s body is %d bytes, over %d limit\", id, len(p.Body), shared.MaxContextBodySize)\n    }\n}","typeGuard":"func bodyWithinLimit(p *shared.UpdateContextParams) bool { return p != nil && int64(len(p.Body)) <= shared.MaxContextBodySize }","tryCatchPattern":"_, err := UpdateContexts(orgId, planId, branch, &req)\nif err != nil && strings.Contains(err.Error(), \"context body is too large\") {\n    // shrink or split the offending body and retry\n}","preventionTips":["Check len(Body) against 25MB before building every update request","Never inline binaries or generated artifacts as context bodies","Summarize or chunk huge files instead of one body"],"tags":["go","context-body","size-limit","update"],"backgroundTag":"payload-size-limit-exceeded","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}