plandex-ai/plandex · error
Max map size exceeded: %d (max %d)
Error message
Max map size exceeded: %d (max %d)
What it means
GetFileMapHandler sums the byte length of every MapInputs value and rejects the request with HTTP 400 if the total exceeds shared.MaxContextMapTotalInputSize (250MB) plus a 10KB grace margin, returning 'Max map size exceeded: %d (max %d)'.
Source
Thrown at app/server/handlers/file_maps.go:52
if len(req.MapInputs) > shared.MaxContextMapPaths {
http.Error(w, fmt.Sprintf("Too many files to map: %d (max %d)", len(req.MapInputs), shared.MaxContextMapPaths), http.StatusBadRequest)
return
}
totalSize := 0
for path, input := range req.MapInputs {
// the client should be truncating inputs to the max size, but we'll check here too
if len(input) > shared.MaxContextMapSingleInputSize {
http.Error(w, fmt.Sprintf("File %s is too large: %d (max %d)", path, len(input), shared.MaxContextMapSingleInputSize), http.StatusBadRequest)
return
}
totalSize += len(input)
}
// On the client, once the total size limit is exceeded, we send empty file maps for remaining files
if totalSize > shared.MaxContextMapTotalInputSize+10000 {
http.Error(w, fmt.Sprintf("Max map size exceeded: %d (max %d)", totalSize, shared.MaxContextMapTotalInputSize), http.StatusBadRequest)
return
}
// Check batch size limits
if len(req.MapInputs) > shared.ContextMapMaxBatchSize {
http.Error(w, fmt.Sprintf("Batch contains too many files: %d (max %d)", len(req.MapInputs), shared.ContextMapMaxBatchSize), http.StatusBadRequest)
return
}
if int64(totalSize) > shared.ContextMapMaxBatchBytes {
http.Error(w, fmt.Sprintf("Batch size too large: %d bytes (max %d bytes)", totalSize, shared.ContextMapMaxBatchBytes), http.StatusBadRequest)
return
}
results := make(chan shared.FileMapBodies, 1)
err := queueProjectMapJob(projectMapJob{
inputs: req.MapInputs,View on GitHub (pinned to e2d772072e)
Solutions
- Reduce total payload below ~250MB by dropping or truncating files
- Send requests in chunks with a running total-size accumulator, mirroring the client behavior of sending empty maps once the cap is hit
- Tighten ignore rules for binary/generated content that inflates total size
- Drop duplicate paths that map to identical large content
Example fix
// before
inputs := collectAll() // 400MB total
send(inputs)
// after
var total int
for path, size := range sizes {
if total+size > shared.MaxContextMapTotalInputSize { break }
inputs[path] = contents[path]; total += size
}
send(inputs) Defensive patterns
Strategy: validation
Validate before calling
// Client-side total-size accounting before sending
total := 0
for _, data := range inputs { total += len(data) }
if total > shared.MaxContextMapTotalInputSize { // 250MB
return fmt.Errorf("total %d bytes exceeds max %d", total, shared.MaxContextMapTotalInputSize)
} Prevention
- Accumulate total size while building the request, not after
- Mirror the CLI behavior of sending empty maps once the total cap is hit
- Exclude binary/bulk content from map inputs
- Split repositories into multiple mapping sessions
When it happens
Trigger: A GetFileMapRequest whose combined file contents exceed 250MB+10KB (per-file 500KB checks may still pass).
Common situations: Bulk-mapping a huge repository snapshot; a client that lost its total-size accounting (the CLI normally sends empty maps once the limit is hit); replaying or multiplying requests in a script.
Related errors
- Too many files to map: %d (max %d)
- Batch size too large: %d bytes (max %d bytes)
- token exchange failed - error creating request: %s
- token exchange failed - error reading body: %s
- token exchange failed - status: %d, body: %s
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/4a4d184da383b16f.
Report an issue: GitHub.