{"record":{"id":"76180bc2efee0916","repo":"plandex-ai/plandex","slug":"map-file-s-exceeds-size-limit-size-d-limit-d","errorCode":null,"errorMessage":"Map file %s exceeds size limit (size %d, limit %d)","messagePattern":"Map file (.+?) exceeds size limit \\(size (.+?), limit (.+?)\\)","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"app/server/handlers/context_helper.go","lineNumber":63,"sourceCode":"\ttotalFiles := 0\n\tmapFilesCount := 0\n\tfor _, context := range *loadReq {\n\t\ttotalFiles++\n\t\tif context.ContextType == shared.ContextMapType {\n\t\t\tmapFilesCount++\n\t\t\tlog.Printf(\"[ContextHelper] Found map file: %s with %d map bodies\", context.FilePath, len(context.MapBodies))\n\n\t\t\tif len(context.MapBodies) > shared.MaxContextMapPaths {\n\t\t\t\tlog.Printf(\"Error: Too many map files to load (found %d, limit is %d)\\n\", len(context.MapBodies), shared.MaxContextMapPaths)\n\t\t\t\thttp.Error(w, fmt.Sprintf(\"Too many map files to load (found %d, limit is %d)\", len(context.MapBodies), shared.MaxContextMapPaths), http.StatusBadRequest)\n\t\t\t\treturn nil, nil\n\t\t\t}\n\n\t\t\t// these are already mapped, so they shouldn't be anywhere close to the input limit, but we'll use it for the sanity check\n\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","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/context_helper.go#L45-L81","documentation":"A per-file sanity check on map contexts: each individual MapBodies entry (a single mapped file's body) must be no larger than shared.MaxContextMapSingleInputSize. If any single mapped file body is bigger, the load is rejected with HTTP 400 before any LLM/db work happens.","triggerScenarios":"Loading a ContextMapType context where at least one body in context.MapBodies has len(body) > shared.MaxContextMapSingleInputSize — typically one huge file inside the mapped tree.","commonSituations":"A generated file, lockfile, vendored dependency, or minified bundle accidentally included in a mapped directory; binary-ish or concatenated data inflating one file's body.","solutions":["Exclude the oversized file from the map (ignore patterns) or map it as regular context after trimming","Split or shrink the offending file","Verify client and server agree on MaxContextMapSingleInputSize (version mismatch)"],"exampleFix":"// before\nmapBodies[path] = readFile(path) // one file over MaxContextMapSingleInputSize\n// after\nbody := readFile(path)\nif len(body) > shared.MaxContextMapSingleInputSize {\n    continue // skip or truncate oversized file before building map\n}\nmapBodies[path] = body","handlingStrategy":"validation","validationCode":"for path, body := range mapBodies {\n    if len(body) > shared.MaxContextMapSingleInputSize {\n        return fmt.Errorf(\"%s exceeds map single-input limit (%d > %d)\", path, len(body), shared.MaxContextMapSingleInputSize)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Skip or chunk oversized files before mapping","Add ignore rules for lockfiles, bundles, and generated artifacts","Alert on files approaching MaxContextMapSingleInputSize in CI"],"tags":["http-400","size-limit","context-map","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"}