plandex-ai/plandex · error
Error getting cached map: %v
Error message
Error getting cached map: %v
What it means
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.
Source
Thrown at app/server/handlers/file_maps.go:169
mu.Lock()
cachedMetaByPath[path] = cachedContext.ToMeta().ToApi()
cachedMapsByPath[path] = &db.CachedMap{
MapParts: cachedContext.MapParts,
MapShas: cachedContext.MapShas,
MapTokens: cachedContext.MapTokens,
MapSizes: cachedContext.MapSizes,
}
mu.Unlock()
}
errCh <- nil
}(path)
}
for range req.FilePaths {
err := <-errCh
if err != nil {
log.Printf("Error getting cached map: %v", err)
http.Error(w, fmt.Sprintf("Error getting cached map: %v", err), http.StatusInternalServerError)
return
}
}
resp := shared.LoadCachedFileMapResponse{}
var loadRes *shared.LoadContextResponse
if len(cachedMetaByPath) == 0 {
log.Println("no cached maps found")
} else {
log.Println("cached map found")
cachedByPath := map[string]bool{}
for _, cachedContext := range cachedMetaByPath {
cachedByPath[cachedContext.FilePath] = true
}
resp.CachedByPath = cachedByPath
View on GitHub (pinned to e2d772072e)
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
Example fix
// before
for range req.FilePaths {
err := <-errCh
if err != nil {
http.Error(w, fmt.Sprintf("Error getting cached map: %v", err), http.StatusInternalServerError)
return
}
}
// after (fail-soft: collect errors, report which paths failed)
var failed []string
for range req.FilePaths {
if err := <-errCh; err != nil {
log.Printf("Error getting cached map: %v", err)
failed = append(failed, err.Error())
}
}
if len(failed) > 0 {
http.Error(w, fmt.Sprintf("Error getting cached maps: %v", failed), http.StatusInternalServerError)
return
} Defensive patterns
Strategy: retry
Validate before calling
// Ensure DB is reachable before issuing the request (ops-side pre-check) // e.g. pg_isready -h $DB_HOST -p $DB_PORT, or a lightweight SELECT 1 health call
Try / catch
for attempt := 0; attempt < 3; attempt++ {
res, err := client.LoadCachedFileMap(ctx, planId, branch, paths)
if err == nil {
return res, nil
}
if strings.Contains(err.Error(), "Error getting cached map") && isTransient(err) {
time.Sleep(backoff(attempt))
continue
}
return err
}
return errors.New("load cached file map failed after retries") Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- error adding plan context tokens: %v
- error adding org member: %v
- error listing org roles: %v
- error adding org user: %v
- error getting plan config: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/33f5663bda9866e0.
Report an issue: GitHub.