{"record":{"id":"f978b53582b1ce68","repo":"plandex-ai/plandex","slug":"map-total-size-is-too-large-d","errorCode":null,"errorMessage":"map total size is too large: %d","messagePattern":"map total size is too large: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/db/context_helpers_update.go","lineNumber":308,"sourceCode":"\n\t\t\t\tfor _, path := range params.RemovedMapPaths {\n\t\t\t\t\tdelete(context.MapParts, path)\n\t\t\t\t\tdelete(context.MapShas, path)\n\t\t\t\t\tdelete(context.MapTokens, path)\n\t\t\t\t\tdelete(context.MapSizes, path)\n\t\t\t\t}\n\n\t\t\t\tif len(context.MapParts) > shared.MaxContextMapPaths {\n\t\t\t\t\terrCh <- fmt.Errorf(\"map has too many paths: %d\", len(context.MapParts))\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\ttotalMapSize := 0\n\t\t\t\tfor _, part := range context.MapParts {\n\t\t\t\t\ttotalMapSize += len(part)\n\t\t\t\t}\n\t\t\t\tif totalMapSize > shared.MaxContextBodySize {\n\t\t\t\t\terrCh <- fmt.Errorf(\"map total size is too large: %d\", totalMapSize)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tcontext.Body = context.MapParts.CombinedMap(context.MapTokens)\n\t\t\t\tnewNumTokens := shared.GetNumTokensEstimate(context.Body)\n\t\t\t\ttokenDiff := newNumTokens - oldNumTokens\n\n\t\t\t\tmu.Lock()\n\t\t\t\ttokenDiffsById[id] = tokenDiff\n\t\t\t\taggregateTokensDiff += tokenDiff\n\t\t\t\ttotalTokens += tokenDiff\n\t\t\t\tif planConfig.AutoLoadContext {\n\t\t\t\t\ttotalMapTokens += tokenDiff\n\t\t\t\t} else {\n\t\t\t\t\ttotalPlannerTokens += tokenDiff\n\t\t\t\t}\n\t\t\t\tmu.Unlock()\n","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/db/context_helpers_update.go#L290-L326","documentation":"After path-count validation, UpdateContexts sums the byte length of all parts in context.MapParts and rejects the update if the total exceeds shared.MaxContextBodySize (25MB). This prevents the combined map body from blowing past context body limits downstream.","triggerScenarios":"A map context update where the merged MapParts total size > 25MB — many medium files each under the 500KB per-part cap but collectively exceeding the aggregate limit.","commonSituations":"Mapping thousands of sizable files (source dumps, datasets); accumulated parts never pruned as files grow across repeated updates; misconfigured clients that skip total-size checks the CLI performs before sending.","solutions":["Trim the mapped path set or per-file excerpts so total size stays under 25MB","Prune unchanged/stale parts from the context before updating","Raise map detail only for files the plan actually needs; use shallow summaries elsewhere","Verify client-side pre-checks (context_load.go checks totalMapSize before sending) are enabled"],"exampleFix":"// before\n// send all parts regardless of total size\n// after\nconst maxTotal = 25 * 1024 * 1024\nif totalSize(mapBodies) > maxTotal {\n    mapBodies = truncateToBudget(mapBodies, maxTotal)\n}","handlingStrategy":"validation","validationCode":"const maxTotal = 25 * 1024 * 1024\ntotal := 0\nfor _, part := range allParts {\n    total += len(part)\n}\nif total > maxTotal {\n    return fmt.Errorf(\"map total %d exceeds 25MB budget\", total)\n}","typeGuard":null,"tryCatchPattern":"err := updateContexts(req)\nif err != nil && strings.Contains(err.Error(), \"map total size is too large\") {\n    return fmt.Errorf(\"shrink the map (fewer paths or smaller excerpts) and retry: %w\", err)\n}","preventionTips":["Budget total map size client-side against the 25MB limit","Prune stale parts before each update","Use excerpts/summaries for large files instead of full bodies","Track totalMapSize incrementally as parts are added"],"tags":["context-map","size-limit","validation","go"],"backgroundTag":"context-body-size-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"}