{"record":{"id":"a9f0f3776a4d70a5","repo":"plandex-ai/plandex","slug":"context-s-exceeds-size-limit-size-2f-mb-limit","errorCode":null,"errorMessage":"Context %s exceeds size limit (size %.2f MB, limit %d MB)","messagePattern":"Context (.+?) exceeds size limit \\(size %\\.2f MB, limit (.+?) MB\\)","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"app/server/handlers/context_helper.go","lineNumber":78,"sourceCode":"\t\t\tfor _, body := range context.MapBodies {\n\t\t\t\tif len(body) > shared.MaxContextMapSingleInputSize {\n\t\t\t\t\tlog.Printf(\"Error: Map file %s exceeds size limit (size %d, limit %d)\\n\", context.FilePath, len(body), shared.MaxContextMapSingleInputSize)\n\t\t\t\t\thttp.Error(w, fmt.Sprintf(\"Map file %s exceeds size limit (size %d, limit %d)\", context.FilePath, len(body), shared.MaxContextMapSingleInputSize), http.StatusBadRequest)\n\t\t\t\t\treturn nil, nil\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif totalFiles > shared.MaxContextCount {\n\t\t\tlog.Printf(\"Error: Too many contexts to load (found %d, limit is %d)\\n\", totalFiles, shared.MaxContextCount)\n\t\t\thttp.Error(w, fmt.Sprintf(\"Too many contexts to load (found %d, limit is %d)\", totalFiles, shared.MaxContextCount), http.StatusBadRequest)\n\t\t\treturn nil, nil\n\t\t}\n\n\t\tfileSize := int64(len(context.Body))\n\t\tif fileSize > shared.MaxContextBodySize {\n\t\t\tlog.Printf(\"Error: Context %s exceeds size limit (size %.2f MB, limit %d MB)\\n\", context.Name, float64(fileSize)/1024/1024, int(shared.MaxContextBodySize)/1024/1024)\n\t\t\thttp.Error(w, fmt.Sprintf(\"Context %s exceeds size limit (size %.2f MB, limit %d MB)\", context.Name, float64(fileSize)/1024/1024, int(shared.MaxContextBodySize)/1024/1024), http.StatusBadRequest)\n\t\t\treturn nil, nil\n\t\t}\n\n\t}\n\n\tif mapFilesCount > 0 {\n\t\tlog.Printf(\"[ContextHelper] Processing %d map files out of %d total contexts\", mapFilesCount, totalFiles)\n\t}\n\n\tvar err error\n\n\tvar settings *shared.PlanSettings\n\tvar clients map[string]model.ClientInfo\n\tvar authVars map[string]string\n\tvar orgUserConfig *shared.OrgUserConfig\n\n\tfor _, context := range *loadReq {\n\t\tif context.ContextType == shared.ContextPipedDataType || context.ContextType == shared.ContextNoteType || context.ContextType == shared.ContextImageType {","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/context_helper.go#L60-L96","documentation":"Each context's Body must be no larger than shared.MaxContextBodySize. If a single context body exceeds it, the server rejects the whole load with HTTP 400, reporting the size in MB against the MB limit.","triggerScenarios":"Loading any context (file, piped data, note, image) whose context.Body length exceeds shared.MaxContextBodySize — e.g. piping a huge log or adding a large generated file.","commonSituations":"Piping large datasets/logs into a plan (cat big.log | plandex); adding build artifacts or datasets; database dumps added as context files.","solutions":["Trim or split the content before adding it as context","Reference only the relevant portion of the large file","Compress/summarize large data instead of loading it whole"],"exampleFix":"// before\nbody, _ := os.ReadFile(\"huge.log\")\nclient.LoadContexts(ctx, planId, branch, []shared.LoadContextParams{{Body: string(body)}})\n// after\nbody, _ := os.ReadFile(\"huge.log\")\nif int64(len(body)) > shared.MaxContextBodySize {\n    body = body[len(body)-int(shared.MaxContextBodySize):] // keep recent tail only\n}\nclient.LoadContexts(ctx, planId, branch, []shared.LoadContextParams{{Body: string(body)}})","handlingStrategy":"validation","validationCode":"for i := range loadReq {\n    if int64(len(loadReq[i].Body)) > shared.MaxContextBodySize {\n        return fmt.Errorf(\"context %s body %d bytes exceeds limit %d\", loadReq[i].Name, len(loadReq[i].Body), shared.MaxContextBodySize)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check file/piped size before adding context and truncate or summarize","Never pipe unbounded streams (logs, dumps) directly into context","Validate sizes client-side in scripts and automation"],"tags":["http-400","size-limit","context-body","plandex"],"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"}