{"record":{"id":"8f7208b0295e5082","repo":"plandex-ai/plandex","slug":"too-many-files-to-map-d-max-d","errorCode":null,"errorMessage":"Too many files to map: %d (max %d)","messagePattern":"Too many files to map: (.+?) \\(max (.+?)\\)","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"app/server/handlers/file_maps.go","lineNumber":36,"sourceCode":"func GetFileMapHandler(w http.ResponseWriter, r *http.Request) {\n\tlog.Println(\"Received request for GetFileMapHandler\")\n\n\tauth := Authenticate(w, r, true)\n\tif auth == nil {\n\t\tlog.Println(\"GetFileMapHandler: auth failed\")\n\t\treturn\n\t}\n\n\tvar req shared.GetFileMapRequest\n\tif err := json.NewDecoder(r.Body).Decode(&req); err != nil {\n\t\thttp.Error(w, fmt.Sprintf(\"Error decoding request: %v\", err), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tlog.Println(\"GetFileMapHandler: checking limits\")\n\n\tif len(req.MapInputs) > shared.MaxContextMapPaths {\n\t\thttp.Error(w, fmt.Sprintf(\"Too many files to map: %d (max %d)\", len(req.MapInputs), shared.MaxContextMapPaths), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\ttotalSize := 0\n\tfor path, input := range req.MapInputs {\n\t\t// the client should be truncating inputs to the max size, but we'll check here too\n\t\tif len(input) > shared.MaxContextMapSingleInputSize {\n\t\t\thttp.Error(w, fmt.Sprintf(\"File %s is too large: %d (max %d)\", path, len(input), shared.MaxContextMapSingleInputSize), http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t\ttotalSize += len(input)\n\t}\n\n\t// On the client, once the total size limit is exceeded, we send empty file maps for remaining files\n\tif totalSize > shared.MaxContextMapTotalInputSize+10000 {\n\t\thttp.Error(w, fmt.Sprintf(\"Max map size exceeded: %d (max %d)\", totalSize, shared.MaxContextMapTotalInputSize), http.StatusBadRequest)\n\t\treturn\n\t}","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/file_maps.go#L18-L54","documentation":"GetFileMapHandler enforces shared.MaxContextMapPaths (3000): if req.MapInputs contains more than 3000 entries the handler rejects the request with HTTP 400 and 'Too many files to map: %d (max %d)' showing the actual count and the 3000 limit.","triggerScenarios":"POSTing a GetFileMapRequest whose MapInputs map has >3000 file-path entries.","commonSituations":"Pointing the client at a monorepo or vendored dependency tree without ignore rules; a recursive directory walk that includes node_modules/.git; batch scripts that skip the client-side MustLoadContext pre-check.","solutions":["Reduce the number of paths sent per request to <= 3000","Apply ignore patterns (vendor, node_modules, generated files) before collecting paths","Split the work into multiple requests of at most 3000 files each","Respect the client-side limit enforced in shared.MustLoadContext, which already blocks >3000 paths"],"exampleFix":"// before\ninputs := allRepoFiles(repoRoot) // 12000 files\nsendMapRequest(inputs)\n// after\nconst maxPaths = shared.MaxContextMapPaths // 3000\nfor _, batch := range chunkPaths(filterIgnored(allRepoFiles(repoRoot)), maxPaths) {\n    sendMapRequest(toInputMap(batch))\n}","handlingStrategy":"validation","validationCode":"// Client-side check before calling the API\nif len(inputs) > shared.MaxContextMapPaths {\n    return fmt.Errorf(\"%d files exceeds max %d; batch them\", len(inputs), shared.MaxContextMapPaths)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enforce the 3000-path cap at collection time, like shared.MustLoadContext does","Filter vendored/generated directories before walking the repo","Chunk large path sets into <=3000-entry requests","Add a client assertion/test that fails fast on oversized path sets"],"tags":["go","http","rate-limit","file-map"],"backgroundTag":"request-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"}