{"record":{"id":"2d90f6528221de7c","repo":"plandex-ai/plandex","slug":"map-is-too-large-d","errorCode":null,"errorMessage":"map is too large: %d","messagePattern":"map is too large: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/db/context_helpers_load.go","lineNumber":181,"sourceCode":"\t\t\t} else {\n\t\t\t\tlog.Println(\"Using map bodies for\", contextParams.FilePath)\n\t\t\t\tmappedFiles = contextParams.MapBodies\n\n\t\t\t\t// check size and num path limits - these should be getting enforced by the client, so just error out if exceeded\n\t\t\t\tif len(mappedFiles) > shared.MaxContextMapPaths {\n\t\t\t\t\treturn nil, nil, fmt.Errorf(\"map has too many paths: %d\", len(mappedFiles))\n\t\t\t\t}\n\n\t\t\t\ttotalMapSize := 0\n\t\t\t\tfor _, body := range mappedFiles {\n\t\t\t\t\tnumBytes := len(body)\n\t\t\t\t\ttotalMapSize += numBytes\n\t\t\t\t\tif numBytes > shared.MaxContextMapSingleInputSize {\n\t\t\t\t\t\treturn nil, nil, fmt.Errorf(\"map input %s is too large: %d\", contextParams.FilePath, numBytes)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif totalMapSize > shared.MaxContextBodySize {\n\t\t\t\t\treturn nil, nil, fmt.Errorf(\"map is too large: %d\", totalMapSize)\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tvar mapShas map[string]string\n\t\t\tvar mapTokens map[string]int\n\t\t\tvar mapSizes map[string]int64\n\n\t\t\tif params.CachedMapsByPath != nil && params.CachedMapsByPath[contextParams.FilePath] != nil {\n\t\t\t\tmapShas = params.CachedMapsByPath[contextParams.FilePath].MapShas\n\t\t\t\tmapTokens = params.CachedMapsByPath[contextParams.FilePath].MapTokens\n\t\t\t\tmapSizes = params.CachedMapsByPath[contextParams.FilePath].MapSizes\n\t\t\t} else {\n\t\t\t\tmapShas = contextParams.InputShas\n\t\t\t\tmapTokens = contextParams.InputTokens\n\t\t\t\tmapSizes = contextParams.InputSizes\n\t\t\t}\n","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/db/context_helpers_load.go#L163-L199","documentation":"LoadContexts returns this when the total size of a map-mode context's bodies exceeds shared.MaxContextBodySize (25MB). Even if each entry is under the 500KB single-input cap, the sum of all map bodies for one context must stay below 25MB.","triggerScenarios":"Calling LoadContexts with contextParams.MapBodies whose summed byte length exceeds 25MB, while all individual entries remain under 500KB.","commonSituations":"Mapping a moderately large directory with many ~100-400KB files; cumulative growth of a map context over many syncs; a client update that raised per-file caps but not total caps.","solutions":["Trim mapped files to the most relevant subset so the total is under 25MB.","Split the map into several map contexts each under the cap.","Use raw file contexts selectively instead of one giant map.","Confirm client-side total-size enforcement matches shared.MaxContextBodySize."],"exampleFix":"// before\nbodies := collectAllMapped() // total 40MB\n// after\nif totalSize(bodies) > shared.MaxContextBodySize {\n    bodies = trimToBudget(bodies, shared.MaxContextBodySize)\n}","handlingStrategy":"validation","validationCode":"total := 0\nfor _, body := range mapBodies { total += len(body) }\nif int64(total) > shared.MaxContextBodySize {\n    return fmt.Errorf(\"map total %d exceeds %d; split or trim\", total, shared.MaxContextBodySize)\n}","typeGuard":"func withinMapTotalLimit(m map[string]string) bool {\n    total := 0\n    for _, b := range m { total += len(b) }\n    return int64(total) <= shared.MaxContextBodySize\n}","tryCatchPattern":null,"preventionTips":["Track cumulative map size while building bodies, not after","Trim to the most relevant files when nearing the 25MB budget","Split oversized maps into several contexts"],"tags":["go","map-context","total-size","limit-exceeded"],"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"}