plandex-ai/plandex · error

File %s is too large: %d (max %d)

Error message

File %s is too large: %d (max %d)

What it means

GetFileMapHandler checks each entry of MapInputs against shared.MaxContextMapSingleInputSize (500KB). If any single file's content exceeds 500KB the handler returns HTTP 400 with 'File %s is too large: %d (max %d)' naming the path, its byte length, and the limit.

Source

Thrown at app/server/handlers/file_maps.go:44

	var req shared.GetFileMapRequest
	if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
		http.Error(w, fmt.Sprintf("Error decoding request: %v", err), http.StatusBadRequest)
		return
	}

	log.Println("GetFileMapHandler: checking limits")

	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 {

View on GitHub (pinned to e2d772072e)

Solutions

  1. Exclude the offending large file (returned in the error path) from MapInputs
  2. Truncate or slice the file content to <= 500KB client-side before sending, as the CLI already does via MaxContextMapSingleInputSize checks
  3. Increase coverage of ignore rules for generated/minified artifacts
  4. If the file is genuinely needed, split it and send only the relevant portion

Example fix

// before
inputs[path] = readFileBytes(path) // 2MB file
// after
b := readFileBytes(path)
if len(b) > shared.MaxContextMapSingleInputSize {
    b = b[:shared.MaxContextMapSingleInputSize]
}
inputs[path] = b
Defensive patterns

Strategy: validation

Validate before calling

// Client-side check per file before sending
for path, data := range inputs {
    if len(data) > shared.MaxContextMapSingleInputSize { // 500KB
        return fmt.Errorf("file %s is %d bytes, max %d", path, len(data), shared.MaxContextMapSingleInputSize)
    }
}

Prevention

When it happens

Trigger: A GetFileMapRequest includes one file whose byte slice is larger than 500*1024 bytes (524288).

Common situations: Committed lockfiles, minified bundles, generated protobufs, JSON dumps, or large fixtures included by an over-broad glob; client-side truncation (getMapFileContent/getMapFileDetails) bypassed or removed.

Related errors


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