plandex-ai/plandex · error
error getting context: %v
Error message
error getting context: %v
What it means
Inside the per-context goroutine, if the context ID is not already in contextsById, UpdateContexts fetches it from the database with GetContext(orgId, planId, id, true, true); this error wraps any failure of that lookup and is sent to errCh, failing the overall update.
Source
Thrown at app/server/db/context_helpers_update.go:157
for id, params := range *req {
go func(id string, params *shared.UpdateContextParams) {
defer func() {
if r := recover(); r != nil {
log.Printf("panic in UpdateContexts: %v\n%s", r, debug.Stack())
errCh <- fmt.Errorf("panic in UpdateContexts: %v\n%s", r, debug.Stack())
runtime.Goexit() // don't allow outer function to continue and double-send to channel
}
}()
var context *Context
if _, ok := contextsById[id]; ok {
context = contextsById[id]
} else {
var err error
context, err = GetContext(orgId, planId, id, true, true)
if err != nil {
errCh <- fmt.Errorf("error getting context: %v", err)
return
}
// log.Println("Got context", context.Id, "numTokens", context.NumTokens)
}
mu.Lock()
defer mu.Unlock()
contextsById[id] = context
updatedContexts = append(updatedContexts, context.ToApi())
if context.ContextType != shared.ContextMapType {
var updateNumTokens int
var err error
if context.ContextType == shared.ContextImageType {
updateNumTokens, err = shared.GetImageTokens(params.Body, context.ImageDetail)
if err != nil {View on GitHub (pinned to e2d772072e)
Solutions
- Verify the context ID exists under the same orgId/planId (e.g. list contexts first) and drop stale IDs.
- Re-fetch the plan's context list to refresh IDs before retrying the update.
- Check DB connectivity/logs if GetContext fails on a known-good ID.
- Handle missing-context IDs gracefully by skipping them instead of including them in the update request.
Example fix
// before
req := map[string]*shared.UpdateContextParams{staleId: {Body: body}}
UpdateContexts(orgId, planId, branch, &req)
// after
existing := ListContextIds(orgId, planId)
for id := range req {
if !slices.Contains(existing, id) {
delete(req, id) // skip stale ids
}
} Defensive patterns
Strategy: try-catch
Validate before calling
ids := ListContextIds(orgId, planId)
for id := range req {
if !slices.Contains(ids, id) { return fmt.Errorf("context %s does not exist for plan %s", id, planId) }
}
Type guard
func contextExists(orgId, planId, id string) bool {
c, err := GetContext(orgId, planId, id, false, false)
return err == nil && c != nil
} Try / catch
err := <-errCh
if err != nil && strings.Contains(err.Error(), "error getting context") {
// refresh context IDs and retry, or skip the missing ID
} Prevention
- Refresh the context ID list before each update; never reuse IDs across plans/orgs
- Pre-load contexts into contextsById where possible so GetContext isn't needed
- Skip missing IDs client-side instead of including them in the request
- Watch DB connectivity; transient read failures also surface here
When it happens
Trigger: Calling UpdateContexts with an ID referencing a context that GetContext cannot load — context doesn't exist under (orgId, planId), the ID is malformed, or the DB read fails (connection error, permissions, missing row).
Common situations: Stale client cache holding IDs of contexts already deleted; IDs copied across plans or orgs; transient database connectivity failure during the update; ID string typos or truncation in caller code.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- no context found with name: %s
- branch not found
- error getting plan config: %v
- error getting default plan config: %v
- error getting default plan config: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/c54eef0a93d95f65.
Report an issue: GitHub.