{"record":{"id":"1c582f51af4703d4","repo":"plandex-ai/plandex","slug":"map-input-s-is-too-large-d-1c582f","errorCode":null,"errorMessage":"map input %s is too large: %d","messagePattern":"map input (.+?) is too large: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/db/context_helpers_update.go","lineNumber":266,"sourceCode":"\terrCh = make(chan error, len(*req))\n\n\tfor id, params := range *req {\n\t\tgo func(id string, params *shared.UpdateContextParams) {\n\t\t\tdefer func() {\n\t\t\t\tif r := recover(); r != nil {\n\t\t\t\t\tlog.Printf(\"panic in UpdateContexts: %v\\n%s\", r, debug.Stack())\n\t\t\t\t\terrCh <- fmt.Errorf(\"panic in UpdateContexts: %v\\n%s\", r, debug.Stack())\n\t\t\t\t\truntime.Goexit() // don't allow outer function to continue and double-send to channel\n\t\t\t\t}\n\t\t\t}()\n\t\t\tcontext := contextsById[id]\n\n\t\t\tif context.ContextType == shared.ContextMapType {\n\t\t\t\toldNumTokens := context.NumTokens\n\n\t\t\t\tfor path, part := range params.MapBodies {\n\t\t\t\t\tif len(part) > shared.MaxContextMapSingleInputSize {\n\t\t\t\t\t\terrCh <- fmt.Errorf(\"map input %s is too large: %d\", path, len(part))\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tif context.MapParts == nil {\n\t\t\t\t\t\tcontext.MapParts = make(shared.FileMapBodies)\n\t\t\t\t\t}\n\t\t\t\t\tif context.MapShas == nil {\n\t\t\t\t\t\tcontext.MapShas = make(map[string]string)\n\t\t\t\t\t}\n\t\t\t\t\tif context.MapTokens == nil {\n\t\t\t\t\t\tcontext.MapTokens = make(map[string]int)\n\t\t\t\t\t}\n\t\t\t\t\tif context.MapSizes == nil {\n\t\t\t\t\t\tcontext.MapSizes = make(map[string]int64)\n\t\t\t\t\t}\n\n\t\t\t\t\t// prevNumTokens := context.MapTokens[path]\n","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/db/context_helpers_update.go#L248-L284","documentation":"For map-type contexts, UpdateContexts validates each entry in params.MapBodies against shared.MaxContextMapSingleInputSize (500KB per path). If any single file's map part exceeds this limit, the update is rejected with the offending path and byte size. The CLI normally truncates oversized files upstream (getMapFileDetails), so this fires when raw/untruncated bodies are sent.","triggerScenarios":"An UpdateContexts call for a map context includes a MapBodies entry whose []byte length > 500*1024 — e.g. a very large generated file, minified bundle, lock file, or dataset committed to the repo and mapped without truncation.","commonSituations":"Large vendored dependencies, node_modules snapshots, compiled artifacts, video/binary blobs, or generated logs included in the plan's file map.","solutions":["Exclude the oversized path from the map update (add it to ignore patterns so it isn't mapped)","Split the file or map only a summary/truncated portion of it","Check the client's truncation logic (shared getMapFileDetails truncates to MaxContextMapSingleInputSize) is actually running","If the file is legitimately needed, reduce its size or store the relevant excerpt instead of the whole file"],"exampleFix":"// before\nmapBodies[path] = fullFileBytes // may exceed 500KB\n// after\nconst maxPart = 500 * 1024\nif len(fullFileBytes) > maxPart {\n    fullFileBytes = fullFileBytes[:maxPart]\n}\nmapBodies[path] = fullFileBytes","handlingStrategy":"validation","validationCode":"const maxSingleInput = 500 * 1024\nfor path, part := range mapBodies {\n    if len(part) > maxSingleInput {\n        return fmt.Errorf(\"path %s is %d bytes (max %d)\", path, len(part), maxSingleInput)\n    }\n}","typeGuard":null,"tryCatchPattern":"err := updateContexts(req)\nif err != nil && strings.Contains(err.Error(), \"is too large\") {\n    // drop or truncate the named path and retry\n    var path string; var size int\n    fmt.Sscanf(err.Error(), \"map input %s is too large: %d\", &path, &size)\n    delete(req.MapBodies, path)\n    return updateContexts(req)\n}","preventionTips":["Truncate map parts to 500KB client-side before sending","Exclude generated artifacts, minified bundles, and binaries from maps","Reuse the library's own truncation helpers (getMapFileDetails)","Pre-check part sizes in CI for pipelines that auto-map files"],"tags":["context-map","size-limit","validation","go"],"backgroundTag":"context-map-input-too-large","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"}