{"record":{"id":"33f5663bda9866e0","repo":"plandex-ai/plandex","slug":"error-getting-cached-map-v-33f566","errorCode":null,"errorMessage":"Error getting cached map: %v","messagePattern":"Error getting cached map: (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/file_maps.go","lineNumber":169,"sourceCode":"\t\t\t\tmu.Lock()\n\t\t\t\tcachedMetaByPath[path] = cachedContext.ToMeta().ToApi()\n\t\t\t\tcachedMapsByPath[path] = &db.CachedMap{\n\t\t\t\t\tMapParts:  cachedContext.MapParts,\n\t\t\t\t\tMapShas:   cachedContext.MapShas,\n\t\t\t\t\tMapTokens: cachedContext.MapTokens,\n\t\t\t\t\tMapSizes:  cachedContext.MapSizes,\n\t\t\t\t}\n\t\t\t\tmu.Unlock()\n\t\t\t}\n\t\t\terrCh <- nil\n\t\t}(path)\n\t}\n\n\tfor range req.FilePaths {\n\t\terr := <-errCh\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Error getting cached map: %v\", err)\n\t\t\thttp.Error(w, fmt.Sprintf(\"Error getting cached map: %v\", err), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t}\n\n\tresp := shared.LoadCachedFileMapResponse{}\n\n\tvar loadRes *shared.LoadContextResponse\n\tif len(cachedMetaByPath) == 0 {\n\t\tlog.Println(\"no cached maps found\")\n\t} else {\n\t\tlog.Println(\"cached map found\")\n\n\t\tcachedByPath := map[string]bool{}\n\t\tfor _, cachedContext := range cachedMetaByPath {\n\t\t\tcachedByPath[cachedContext.FilePath] = true\n\t\t}\n\t\tresp.CachedByPath = cachedByPath\n","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/file_maps.go#L151-L187","documentation":"LoadCachedFileMapHandler loads cached file maps concurrently, one goroutine per path, each sending its result (nil or an error like 'error getting cached map: ...') on errCh. If any goroutine reports an error from db.GetCachedMap (or panics, which are converted into an error), the handler aborts with this 500 message carrying the underlying cause.","triggerScenarios":"Any req.FilePaths entry fails db.GetCachedMap(plan.OrgId, plan.ProjectId, path) — DB connection failure, missing/rolled-back migration for the cached maps table, a panic inside a goroutine (recovered and forwarded), or a database row for the path that cannot be deserialized.","commonSituations":"Postgres is down, unreachable, or out of connections; DATABASE_URL misconfigured in the environment; schema migration not applied after upgrading Plandex; a stale/corrupt cached map row; requesting a path with characters that break the lookup.","solutions":["Read the underlying cause after 'Error getting cached map: ' in the response/log — it names the actual DB error","Check database connectivity from the server (DATABASE_URL, network, pg_isready) and confirm the Postgres instance is healthy","Apply pending schema migrations for the Plandex database, then retry the request","Retry the request — transient DB errors (connection reset, lock timeout) often clear; investigate corrupt rows if one specific path always fails"],"exampleFix":"// before\nfor range req.FilePaths {\n    err := <-errCh\n    if err != nil {\n        http.Error(w, fmt.Sprintf(\"Error getting cached map: %v\", err), http.StatusInternalServerError)\n        return\n    }\n}\n// after (fail-soft: collect errors, report which paths failed)\nvar failed []string\nfor range req.FilePaths {\n    if err := <-errCh; err != nil {\n        log.Printf(\"Error getting cached map: %v\", err)\n        failed = append(failed, err.Error())\n    }\n}\nif len(failed) > 0 {\n    http.Error(w, fmt.Sprintf(\"Error getting cached maps: %v\", failed), http.StatusInternalServerError)\n    return\n}","handlingStrategy":"retry","validationCode":"// Ensure DB is reachable before issuing the request (ops-side pre-check)\n// e.g. pg_isready -h $DB_HOST -p $DB_PORT, or a lightweight SELECT 1 health call","typeGuard":null,"tryCatchPattern":"for attempt := 0; attempt < 3; attempt++ {\n    res, err := client.LoadCachedFileMap(ctx, planId, branch, paths)\n    if err == nil {\n        return res, nil\n    }\n    if strings.Contains(err.Error(), \"Error getting cached map\") && isTransient(err) {\n        time.Sleep(backoff(attempt))\n        continue\n    }\n    return err\n}\nreturn errors.New(\"load cached file map failed after retries\")","preventionTips":["Monitor Postgres health and connection-pool saturation","Apply database migrations on every server upgrade","Alert on repeated 'Error getting cached map' 500s — indicates persistent DB or corrupt-row issues","Retry only transient DB errors; a failing specific path points at corrupt data, not load"],"tags":["database","postgres","concurrency","go"],"backgroundTag":"database-query-failed","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"}