{"record":{"id":"a0f5b204ce327b00","repo":"plandex-ai/plandex","slug":"context-body-is-too-large-d","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_load.go","lineNumber":116,"sourceCode":"\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"error getting existing contexts: %v\", err)\n\t}\n\n\t// check overall context limits - these should be getting enforced by the client, so just error out if exceeded\n\tnumExistingContexts := len(existingContexts)\n\tif numExistingContexts+len(*req) > shared.MaxContextCount {\n\t\treturn nil, nil, fmt.Errorf(\"too many contexts: %d\", numExistingContexts+len(*req))\n\t}\n\n\tvar totalContextSize int64\n\tfor _, context := range existingContexts {\n\t\ttotalContextSize += context.BodySize\n\t}\n\tfor _, context := range *req {\n\t\tsize := int64(len(context.Body))\n\t\ttotalContextSize += size\n\t\tif size > shared.MaxContextBodySize {\n\t\t\treturn nil, nil, fmt.Errorf(\"context body is too large: %d\", size)\n\t\t}\n\t}\n\n\tif totalContextSize > shared.MaxTotalContextSize {\n\t\treturn nil, nil, fmt.Errorf(\"total context size is too large: %d\", totalContextSize)\n\t}\n\n\texistingContextsByName := make(map[string]bool)\n\tfor _, context := range existingContexts {\n\t\tcomposite := strings.Join([]string{context.Name, string(context.ContextType)}, \"|\")\n\t\texistingContextsByName[composite] = true\n\n\t\tif planConfig.AutoLoadContext && context.ContextType == shared.ContextMapType {\n\t\t\ttotalMapTokens += context.NumTokens\n\t\t\ttotalPlannerTokens -= context.NumTokens\n\t\t}\n\n\t\tif !context.AutoLoaded && context.ContextType != shared.ContextMapType {","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/db/context_helpers_load.go#L98-L134","documentation":"LoadContexts rejects any single incoming context whose body exceeds shared.MaxContextBodySize bytes. The size is computed as len(context.Body) server-side; the client should have prevented this, so the error indicates an oversized file/blob was submitted directly to the API.","triggerScenarios":"A LoadContexts request containing one context with len(Body) > shared.MaxContextBodySize — typically a very large file loaded via direct API call or an automation that skips client checks.","commonSituations":"Loading generated artifacts (build outputs, lockfiles, datasets, minified bundles) that exceed the per-context size cap; API scripts passing whole large files; binary files base64-bloated past the limit.","solutions":["Remove or ignore the oversized file (add it to .plandexignore / don't load it).","Load only the relevant portion of the file (split or excerpt it).","For generated files, exclude build/dependency directories from context loads.","If an API caller, check len(body) <= shared.MaxContextBodySize before submitting."],"exampleFix":"// before: sending the whole file\ndata, _ := os.ReadFile(\"dist/bundle.js\")\nparams := shared.LoadContextParams{Body: string(data)}\n// after: guard on client side\nconst MaxContextBodySize = 200 * 1024 // shared.MaxContextBodySize\nif len(data) > MaxContextBodySize {\n\treturn fmt.Errorf(\"file too large for context: %d bytes\", len(data))\n}","handlingStrategy":"validation","validationCode":"func withinBodyLimit(body string) bool {\n\treturn int64(len(body)) <= shared.MaxContextBodySize\n}\nfor _, p := range reqParams {\n\tif !withinBodyLimit(p.Body) {\n\t\treturn fmt.Errorf(\"skipping %s: body exceeds MaxContextBodySize\", p.Name)\n\t}\n}","typeGuard":null,"tryCatchPattern":"_, err := client.LoadContexts(req)\nif err != nil {\n\tif strings.Contains(err.Error(), \"context body is too large\") {\n\t\t// extract reported size, split or excerpt the offending file, resubmit\n\t\treturn splitAndRetry(err)\n\t}\n\treturn err\n}","preventionTips":["Check len(body) against MaxContextBodySize before submitting","Exclude generated artifacts and minified bundles from context loads","Use .plandexignore to keep large files out of loads","Split very large files into smaller excerpts before loading"],"tags":["limits","server","contexts","file-size"],"backgroundTag":"context-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"}