plandex-ai/plandex · error
map input %s is too large: %d
Error message
map input %s is too large: %d
What it means
For map-type contexts, UpdateContexts validates each entry in params.MapBodies against shared.MaxContextMapSingleInputSize (500KB per path). If any single file's map part exceeds this limit, the update is rejected with the offending path and byte size. The CLI normally truncates oversized files upstream (getMapFileDetails), so this fires when raw/untruncated bodies are sent.
Source
Thrown at app/server/db/context_helpers_update.go:266
errCh = make(chan error, len(*req))
for id, params := range *req {
go func(id string, params *shared.UpdateContextParams) {
defer func() {
if r := recover(); r != nil {
log.Printf("panic in UpdateContexts: %v\n%s", r, debug.Stack())
errCh <- fmt.Errorf("panic in UpdateContexts: %v\n%s", r, debug.Stack())
runtime.Goexit() // don't allow outer function to continue and double-send to channel
}
}()
context := contextsById[id]
if context.ContextType == shared.ContextMapType {
oldNumTokens := context.NumTokens
for path, part := range params.MapBodies {
if len(part) > shared.MaxContextMapSingleInputSize {
errCh <- fmt.Errorf("map input %s is too large: %d", path, len(part))
return
}
if context.MapParts == nil {
context.MapParts = make(shared.FileMapBodies)
}
if context.MapShas == nil {
context.MapShas = make(map[string]string)
}
if context.MapTokens == nil {
context.MapTokens = make(map[string]int)
}
if context.MapSizes == nil {
context.MapSizes = make(map[string]int64)
}
// prevNumTokens := context.MapTokens[path]
View on GitHub (pinned to e2d772072e)
Solutions
- Exclude the oversized path from the map update (add it to ignore patterns so it isn't mapped)
- Split the file or map only a summary/truncated portion of it
- Check the client's truncation logic (shared getMapFileDetails truncates to MaxContextMapSingleInputSize) is actually running
- If the file is legitimately needed, reduce its size or store the relevant excerpt instead of the whole file
Example fix
// before
mapBodies[path] = fullFileBytes // may exceed 500KB
// after
const maxPart = 500 * 1024
if len(fullFileBytes) > maxPart {
fullFileBytes = fullFileBytes[:maxPart]
}
mapBodies[path] = fullFileBytes Defensive patterns
Strategy: validation
Validate before calling
const maxSingleInput = 500 * 1024
for path, part := range mapBodies {
if len(part) > maxSingleInput {
return fmt.Errorf("path %s is %d bytes (max %d)", path, len(part), maxSingleInput)
}
} Try / catch
err := updateContexts(req)
if err != nil && strings.Contains(err.Error(), "is too large") {
// drop or truncate the named path and retry
var path string; var size int
fmt.Sscanf(err.Error(), "map input %s is too large: %d", &path, &size)
delete(req.MapBodies, path)
return updateContexts(req)
} Prevention
- Truncate map parts to 500KB client-side before sending
- Exclude generated artifacts, minified bundles, and binaries from maps
- Reuse the library's own truncation helpers (getMapFileDetails)
- Pre-check part sizes in CI for pipelines that auto-map files
When it happens
Trigger: An UpdateContexts call for a map context includes a MapBodies entry whose []byte length > 500*1024 — e.g. a very large generated file, minified bundle, lock file, or dataset committed to the repo and mapped without truncation.
Common situations: Large vendored dependencies, node_modules snapshots, compiled artifacts, video/binary blobs, or generated logs included in the plan's file map.
Related errors
- map has too many paths: %d
- map total size is too large: %d
- invalid context index: %s
- no context found with name: %s
- invalid value: %s
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/1c582f51af4703d4.
Report an issue: GitHub.