{"record":{"id":"9e42a0fd1834c358","repo":"plandex-ai/plandex","slug":"error-updating-context-v","errorCode":null,"errorMessage":"error updating context: %v","messagePattern":"error updating context: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/lib/context_update.go","lineNumber":189,"sourceCode":"\t\tconfirmed, err = term.ConfirmYesNo(\"Update context now?\")\n\n\t\tif err != nil {\n\t\t\tterm.OutputErrorAndExit(\"failed to get user input: %s\", err)\n\t\t}\n\t}\n\n\tif confirmed {\n\t\treqFn := outdatedRes.ReqFn\n\t\tif reqFn == nil {\n\t\t\treturn false, false, fmt.Errorf(\"no update request function provided\")\n\t\t}\n\t\t_, err = UpdateContextWithOutput(UpdateContextParams{\n\t\t\tContexts:    contexts,\n\t\t\tOutdatedRes: *outdatedRes,\n\t\t\tReqFn:       reqFn,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn false, false, fmt.Errorf(\"error updating context: %v\", err)\n\t\t}\n\t\treturn true, true, nil\n\t} else {\n\t\treturn true, false, nil\n\t}\n\n}\n\ntype UpdateContextParams struct {\n\tContexts    []*shared.Context\n\tOutdatedRes types.ContextOutdatedResult\n\tReqFn       func() (map[string]*shared.UpdateContextParams, error)\n}\n\ntype UpdateContextResult struct {\n\tHasConflicts bool\n\tMsg          string\n}","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/lib/context_update.go#L171-L207","documentation":"Wrapper error from CheckOutdatedContextWithOutput when the confirmed context update (via UpdateContextWithOutput -> UpdateContext) fails for any reason — reqFn failure, conflict-check failure, or the UpdateContext/DeleteContext API calls. The wrapped %v carries the real cause from UpdateContext.","triggerScenarios":"User confirms 'Update context now?' (or autoConfirm=true) and UpdateContextWithOutput returns an error: reqFn() fails, context conflict check fails, or api.Client.UpdateContext / DeleteContext returns an error (auth expired, network, plan locked).","commonSituations":"Server unreachable or session token expired while applying an update; local files changed again mid-update causing conflicts; deleteIds referencing contexts already deleted on the server from another session.","solutions":["Read the wrapped inner error — it distinguishes reqFn failure vs conflict-check failure vs API failure","Re-authenticate if the inner error is 401/403 (plandex sign-in)","Retry after network issues; the plan context is only mutated on success of each API call","Run plandex context to list current context and resolve conflicts before updating"],"exampleFix":"// before: letting the error bubble and aborting the command\n_, _, err := lib.CheckOutdatedContextWithOutput(false, false, nil, paths)\nif err != nil { return err }\n// after: handle update failure without losing the outdated info\n_, _, err := lib.CheckOutdatedContextWithOutput(false, false, nil, paths)\nif err != nil {\n    fmt.Println(\"context update failed; run `plandex context update` after fixing:\", err)\n}","handlingStrategy":"try-catch","validationCode":"// pre-check auth and plan state before confirming the update\nif _, err := api.Client.ListContext(CurrentPlanId, CurrentBranch); err != nil {\n    return fmt.Errorf(\"cannot reach plan context (auth/network?): %w\", err)\n}","typeGuard":null,"tryCatchPattern":"_, _, err := lib.CheckOutdatedContextWithOutput(false, false, nil, paths)\nif err != nil && strings.Contains(err.Error(), \"error updating context\") {\n    // parse inner cause; retry on transient network errors\n    if isTransient(err) { time.Sleep(time.Second); return retry() }\n    return fmt.Errorf(\"context update failed: %w\", err)\n}","preventionTips":["Refresh auth tokens before long sessions","Avoid concurrent context updates on the same plan/branch","Handle user decline gracefully instead of forcing autoConfirm","Run `plandex context` first to preview what will change"],"tags":["go","api","context","error-wrapping"],"backgroundTag":"context-update-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}