plandex-ai/plandex · error

Error getting cached map

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.

Solutions

  1. Read the underlying cause after 'Error getting cached map: ' in the response/log — it names the actual DB error
  2. Check database connectivity from the server (DATABASE_URL, network, pg_isready) and confirm the Postgres instance is healthy
  3. Apply pending schema migrations for the Plandex database, then retry the request
  4. 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

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


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/33f5663bda9866e0. Report an issue: GitHub.

Appendix: 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)