{"record":{"id":"99268ef3350efecc","repo":"plandex-ai/plandex","slug":"too-many-map-files-to-load-found-d-limit-is-d","errorCode":null,"errorMessage":"Too many map files to load (found %d, limit is %d)","messagePattern":"Too many map files to load \\(found (.+?), limit is (.+?)\\)","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"app/server/handlers/context_helper.go","lineNumber":55,"sourceCode":"\tbranchName := params.branchName\n\tcachedMapsByPath := params.cachedMapsByPath\n\tautoLoaded := params.autoLoaded\n\n\tlog.Printf(\"[ContextHelper] Starting loadContexts with %d contexts, cachedMapsByPath: %v, autoLoaded: %v\", len(*loadReq), cachedMapsByPath != nil, autoLoaded)\n\n\t// check file count and size limits\n\t// this is all a sanity check - we should have already checked these limits in the client\n\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}","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/context_helper.go#L37-L73","documentation":"loadContexts is a server-side sanity check on context map loads. When a map-type context arrives with more MapBodies (individual mapped file paths) than shared.MaxContextMapPaths allows, the server refuses the load and returns HTTP 400. The client is expected to enforce this limit before sending, so hitting it means an oversized map was built or sent by an outdated/nonstandard client.","triggerScenarios":"Calling LoadContexts / AutoLoadContext (or the cached-map and missing-file handlers) with a ContextMapType context whose MapBodies slice exceeds shared.MaxContextMapPaths — e.g. mapping a huge directory tree.","commonSituations":"Mapping a very large monorepo or node_modules-like directory; an old client version with a lower local limit than the server; scripts that add maps programmatically without pre-checking the path count.","solutions":["Reduce the number of files being mapped (map subdirectories individually or add ignores)","Upgrade the Plandex client so it enforces the same MaxContextMapPaths limit before sending","Check the shared.MaxContextMapPaths value in the deployed server version and stay under it"],"exampleFix":"// before\ncontexts = append(contexts, shared.LoadContextParams{ContextType: shared.ContextMapType, MapBodies: allBodies}) // may exceed limit\n// after\nif len(allBodies) > shared.MaxContextMapPaths {\n    allBodies = allBodies[:shared.MaxContextMapPaths] // or split into multiple map contexts\n}\ncontexts = append(contexts, shared.LoadContextParams{ContextType: shared.ContextMapType, MapBodies: allBodies})","handlingStrategy":"validation","validationCode":"if len(mapParams.MapBodies) > shared.MaxContextMapPaths {\n    return fmt.Errorf(\"too many map paths: %d (limit %d)\", len(mapParams.MapBodies), shared.MaxContextMapPaths)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Count MapBodies before building a map context and split large trees","Keep client and server on the same version so limits match","Configure ignores to exclude vendor/generated directories from maps"],"tags":["http-400","limit-exceeded","context-map","plandex"],"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"}