plandex-ai/plandex · error
map has too many paths: %d
Error message
map has too many paths: %d
What it means
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.
Source
Thrown at app/server/db/context_helpers_load.go:169
var numTokens int
var err error
var isMap bool
if contextParams.ContextType == shared.ContextMapType && (len(contextParams.MapBodies) > 0 || params.CachedMapsByPath != nil) {
isMap = true
var mappedFiles shared.FileMapBodies
if params.CachedMapsByPath != nil && params.CachedMapsByPath[contextParams.FilePath] != nil {
log.Println("Using cached map for", contextParams.FilePath)
mappedFiles = params.CachedMapsByPath[contextParams.FilePath].MapParts
} else {
log.Println("Using map bodies for", contextParams.FilePath)
mappedFiles = contextParams.MapBodies
// check size and num path limits - these should be getting enforced by the client, so just error out if exceeded
if len(mappedFiles) > shared.MaxContextMapPaths {
return nil, nil, fmt.Errorf("map has too many paths: %d", len(mappedFiles))
}
totalMapSize := 0
for _, body := range mappedFiles {
numBytes := len(body)
totalMapSize += numBytes
if numBytes > shared.MaxContextMapSingleInputSize {
return nil, nil, fmt.Errorf("map input %s is too large: %d", contextParams.FilePath, numBytes)
}
}
if totalMapSize > shared.MaxContextBodySize {
return nil, nil, fmt.Errorf("map is too large: %d", totalMapSize)
}
}
var mapShas map[string]string
var mapTokens map[string]intView on GitHub (pinned to e2d772072e)
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.
Example fix
// before
mapBodies := buildMapBodies(allFiles) // 5000 paths
LoadContexts(ctx, ctxParams{MapBodies: mapBodies})
// after
if len(mapBodies) > shared.MaxContextMapPaths {
mapBodies = filterToRelevantPaths(mapBodies) // or split into several contexts
} Defensive patterns
Strategy: validation
Validate before calling
if len(mapBodies) > shared.MaxContextMapPaths {
return fmt.Errorf("%d paths exceeds limit %d; split the map context", len(mapBodies), shared.MaxContextMapPaths)
} Type guard
func withinMapPathLimit(m map[string]string) bool { return len(m) <= shared.MaxContextMapPaths } Prevention
- 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
When it happens
Trigger: Calling LoadContexts with contextParams.MapBodies containing more than 3000 entries, when the client chose the 'map bodies' path instead of raw bodies.
Common situations: 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.
Related errors
- map input %s is too large: %d
- map is too large: %d
- total context size is too large: %d
- too many contexts to update (found %d, limit is %d)
- connection to plan stream timed out due to missing heartbeat
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/f49d31dd64a59347.
Report an issue: GitHub.