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]int

View on GitHub (pinned to e2d772072e)

Solutions

  1. Split the map context into multiple contexts each with <=3000 paths.
  2. Limit the mapped directory scope (ignore node_modules, vendored dirs, build outputs).
  3. 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

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


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/f49d31dd64a59347. Report an issue: GitHub.