{"record":{"id":"f49d31dd64a59347","repo":"plandex-ai/plandex","slug":"map-has-too-many-paths-d","errorCode":null,"errorMessage":"map has too many paths: %d","messagePattern":"map has too many paths: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/db/context_helpers_load.go","lineNumber":169,"sourceCode":"\n\t\tvar numTokens int\n\t\tvar err error\n\n\t\tvar isMap bool\n\n\t\tif contextParams.ContextType == shared.ContextMapType && (len(contextParams.MapBodies) > 0 || params.CachedMapsByPath != nil) {\n\t\t\tisMap = true\n\t\t\tvar mappedFiles shared.FileMapBodies\n\t\t\tif params.CachedMapsByPath != nil && params.CachedMapsByPath[contextParams.FilePath] != nil {\n\t\t\t\tlog.Println(\"Using cached map for\", contextParams.FilePath)\n\t\t\t\tmappedFiles = params.CachedMapsByPath[contextParams.FilePath].MapParts\n\t\t\t} else {\n\t\t\t\tlog.Println(\"Using map bodies for\", contextParams.FilePath)\n\t\t\t\tmappedFiles = contextParams.MapBodies\n\n\t\t\t\t// check size and num path limits - these should be getting enforced by the client, so just error out if exceeded\n\t\t\t\tif len(mappedFiles) > shared.MaxContextMapPaths {\n\t\t\t\t\treturn nil, nil, fmt.Errorf(\"map has too many paths: %d\", len(mappedFiles))\n\t\t\t\t}\n\n\t\t\t\ttotalMapSize := 0\n\t\t\t\tfor _, body := range mappedFiles {\n\t\t\t\t\tnumBytes := len(body)\n\t\t\t\t\ttotalMapSize += numBytes\n\t\t\t\t\tif numBytes > shared.MaxContextMapSingleInputSize {\n\t\t\t\t\t\treturn nil, nil, fmt.Errorf(\"map input %s is too large: %d\", contextParams.FilePath, numBytes)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif totalMapSize > shared.MaxContextBodySize {\n\t\t\t\t\treturn nil, nil, fmt.Errorf(\"map is too large: %d\", totalMapSize)\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tvar mapShas map[string]string\n\t\t\tvar mapTokens map[string]int","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/db/context_helpers_load.go#L151-L187","documentation":"LoadContexts returns this when the map-mode context being loaded contains more file paths than shared.MaxContextMapPaths (3000). Map paths are enforced client-side; the server just errors out defensively if a client sends an oversized path map.","triggerScenarios":"Calling LoadContexts with contextParams.MapBodies containing more than 3000 entries, when the client chose the 'map bodies' path instead of raw bodies.","commonSituations":"Mapping a very large repository or monorepo directory into a single map context, a stale client version that no longer batches map paths to <=3000, or manually constructing map bodies via the API.","solutions":["Split the map context into multiple contexts each with <=3000 paths.","Limit the mapped directory scope (ignore node_modules, vendored dirs, build outputs).","Update the client so it enforces MaxContextMapPaths and batches before sending."],"exampleFix":"// before\nmapBodies := buildMapBodies(allFiles) // 5000 paths\nLoadContexts(ctx, ctxParams{MapBodies: mapBodies})\n// after\nif len(mapBodies) > shared.MaxContextMapPaths {\n    mapBodies = filterToRelevantPaths(mapBodies) // or split into several contexts\n}","handlingStrategy":"validation","validationCode":"if len(mapBodies) > shared.MaxContextMapPaths {\n    return fmt.Errorf(\"%d paths exceeds limit %d; split the map context\", len(mapBodies), shared.MaxContextMapPaths)\n}","typeGuard":"func withinMapPathLimit(m map[string]string) bool { return len(m) <= shared.MaxContextMapPaths }","tryCatchPattern":null,"preventionTips":["Cap the number of files mapped per context at 3000","Ignore vendored/node_modules/build directories when building map bodies","Split very large directory mappings across multiple contexts","Update clients that predate the MaxContextMapPaths enforcement"],"tags":["go","map-context","path-limit","limit-exceeded"],"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-14T00:17:10.932Z"}