{"record":{"id":"7212d9a495ad477a","repo":"plandex-ai/plandex","slug":"map-input-s-is-too-large-d","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_load.go","lineNumber":177,"sourceCode":"\t\t\tvar mappedFiles shared.FileMapBodies\n\t\t\tif params.CachedMapsByPath != nil && params.CachedMapsByPath[contextParams.FilePath] != nil {\n\t\t\t\tlog.Println(\"Using cached map for\", contextParams.FilePath)\n\t\t\t\tmappedFiles = params.CachedMapsByPath[contextParams.FilePath].MapParts\n\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","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/db/context_helpers_load.go#L159-L195","documentation":"Server-side size guard in LoadContexts: the number of map bodies for a context input exceeds shared.MaxContextMapPaths. Clients are expected to enforce this limit, so hitting it means a misbehaving/outdated client or forged request sent too many mapped paths.","triggerScenarios":"Calling LoadContexts with contextParams.MapBodies where at least one value's byte length exceeds 500KB; the error names the offending contextParams.FilePath and the byte count.","commonSituations":"A single huge generated file, minified JS bundle, lockfile, or dataset got included in the map; copying file contents with the wrong variable so one map value holds the concatenation of many files.","solutions":["Exclude the oversized file from the map context (add it to ignore patterns).","Split the oversized file into chunks or load it as a regular (non-map) context if <=25MB applies.","Compress or truncate the input before putting it in MapBodies.","Verify client code isn't concatenating multiple files into one map entry."],"exampleFix":"// before\nbodies[path] = string(fileBytes) // 2MB single file\n// after\nif len(fileBytes) > shared.MaxContextMapSingleInputSize {\n    continue // skip or chunk the oversized file\n}\nbodies[path] = string(fileBytes)","handlingStrategy":"validation","validationCode":"for path, body := range mapBodies {\n    if int64(len(body)) > shared.MaxContextMapSingleInputSize {\n        return fmt.Errorf(\"%s is %d bytes, over %d limit\", path, len(body), shared.MaxContextMapSingleInputSize)\n    }\n}","typeGuard":"func withinSingleInputLimit(body string) bool { return int64(len(body)) <= shared.MaxContextMapSingleInputSize }","tryCatchPattern":null,"preventionTips":["Skip or chunk files larger than 500KB before adding to MapBodies","Maintain an ignore list for minified bundles, lockfiles, and datasets","Assert no map value holds concatenated content of multiple files"],"tags":["go","map-context","single-input-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-12T22:17:10.623Z"}