{"record":{"id":"4a4d184da383b16f","repo":"plandex-ai/plandex","slug":"max-map-size-exceeded-d-max-d","errorCode":null,"errorMessage":"Max map size exceeded: %d (max %d)","messagePattern":"Max map size exceeded: (.+?) \\(max (.+?)\\)","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"app/server/handlers/file_maps.go","lineNumber":52,"sourceCode":"\n\tif len(req.MapInputs) > shared.MaxContextMapPaths {\n\t\thttp.Error(w, fmt.Sprintf(\"Too many files to map: %d (max %d)\", len(req.MapInputs), shared.MaxContextMapPaths), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\ttotalSize := 0\n\tfor path, input := range req.MapInputs {\n\t\t// the client should be truncating inputs to the max size, but we'll check here too\n\t\tif len(input) > shared.MaxContextMapSingleInputSize {\n\t\t\thttp.Error(w, fmt.Sprintf(\"File %s is too large: %d (max %d)\", path, len(input), shared.MaxContextMapSingleInputSize), http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t\ttotalSize += len(input)\n\t}\n\n\t// On the client, once the total size limit is exceeded, we send empty file maps for remaining files\n\tif totalSize > shared.MaxContextMapTotalInputSize+10000 {\n\t\thttp.Error(w, fmt.Sprintf(\"Max map size exceeded: %d (max %d)\", totalSize, shared.MaxContextMapTotalInputSize), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\t// Check batch size limits\n\tif len(req.MapInputs) > shared.ContextMapMaxBatchSize {\n\t\thttp.Error(w, fmt.Sprintf(\"Batch contains too many files: %d (max %d)\", len(req.MapInputs), shared.ContextMapMaxBatchSize), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif int64(totalSize) > shared.ContextMapMaxBatchBytes {\n\t\thttp.Error(w, fmt.Sprintf(\"Batch size too large: %d bytes (max %d bytes)\", totalSize, shared.ContextMapMaxBatchBytes), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tresults := make(chan shared.FileMapBodies, 1)\n\n\terr := queueProjectMapJob(projectMapJob{\n\t\tinputs:  req.MapInputs,","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/file_maps.go#L34-L70","documentation":"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)'.","triggerScenarios":"A GetFileMapRequest whose combined file contents exceed 250MB+10KB (per-file 500KB checks may still pass).","commonSituations":"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.","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"],"exampleFix":"// before\ninputs := collectAll() // 400MB total\nsend(inputs)\n// after\nvar total int\nfor path, size := range sizes {\n    if total+size > shared.MaxContextMapTotalInputSize { break }\n    inputs[path] = contents[path]; total += size\n}\nsend(inputs)","handlingStrategy":"validation","validationCode":"// Client-side total-size accounting before sending\ntotal := 0\nfor _, data := range inputs { total += len(data) }\nif total > shared.MaxContextMapTotalInputSize { // 250MB\n    return fmt.Errorf(\"total %d bytes exceeds max %d\", total, shared.MaxContextMapTotalInputSize)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["go","http","payload-size","file-map"],"backgroundTag":"payload-size-limit-exceeded","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}