plandex-ai/plandex · error
map input %s is too large: %d
Error message
map input %s is too large: %d
What it means
Server-side size guard in LoadContexts: the number of map bodies for a context input exceeds shared.MaxContextMapPaths. Clients are expected to enforce this limit, so hitting it means a misbehaving/outdated client or forged request sent too many mapped paths.
Source
Thrown at app/server/db/context_helpers_load.go:177
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
var mapSizes map[string]int64
if params.CachedMapsByPath != nil && params.CachedMapsByPath[contextParams.FilePath] != nil {
mapShas = params.CachedMapsByPath[contextParams.FilePath].MapShas
mapTokens = params.CachedMapsByPath[contextParams.FilePath].MapTokens
mapSizes = params.CachedMapsByPath[contextParams.FilePath].MapSizes
} else {
mapShas = contextParams.InputShasView on GitHub (pinned to e2d772072e)
Solutions
- Exclude the oversized file from the map context (add it to ignore patterns).
- Split the oversized file into chunks or load it as a regular (non-map) context if <=25MB applies.
- Compress or truncate the input before putting it in MapBodies.
- Verify client code isn't concatenating multiple files into one map entry.
Example fix
// before
bodies[path] = string(fileBytes) // 2MB single file
// after
if len(fileBytes) > shared.MaxContextMapSingleInputSize {
continue // skip or chunk the oversized file
}
bodies[path] = string(fileBytes) Defensive patterns
Strategy: validation
Validate before calling
for path, body := range mapBodies {
if int64(len(body)) > shared.MaxContextMapSingleInputSize {
return fmt.Errorf("%s is %d bytes, over %d limit", path, len(body), shared.MaxContextMapSingleInputSize)
}
} Type guard
func withinSingleInputLimit(body string) bool { return int64(len(body)) <= shared.MaxContextMapSingleInputSize } Prevention
- Skip or chunk files larger than 500KB before adding to MapBodies
- Maintain an ignore list for minified bundles, lockfiles, and datasets
- Assert no map value holds concatenated content of multiple files
When it happens
Trigger: Calling LoadContexts with contextParams.MapBodies where at least one value's byte length exceeds 500KB; the error names the offending contextParams.FilePath and the byte count.
Common situations: A single huge generated file, minified JS bundle, lockfile, or dataset got included in the map; copying file contents with the wrong variable so one map value holds the concatenation of many files.
Related errors
- map has too many paths: %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/7212d9a495ad477a.
Report an issue: GitHub.