{"record":{"id":"cbcf865feaaf88a3","repo":"plandex-ai/plandex","slug":"failed-to-load-context-v-cbcf86","errorCode":null,"errorMessage":"failed to load context: %v","messagePattern":"failed to load context: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/lib/context_load.go","lineNumber":727,"sourceCode":"\t\t\tfmt.Println()\n\t\t\tfmt.Printf(\"%s with the -n flag:\\n\", color.New(color.Bold, term.ColorHiCyan).Sprint(\"Load a note\"))\n\t\t\tfmt.Println(\"plandex load -n 'Some note here'\")\n\n\t\t\tfmt.Println()\n\t\t\tfmt.Printf(\"%s from any command:\\n\", color.New(color.Bold, term.ColorHiCyan).Sprint(\"Pipe data in\"))\n\t\t\tfmt.Println(\"npm test | plandex load\")\n\t\t}\n\n\t\tos.Exit(0)\n\t}\n\n\tvar res *shared.LoadContextResponse\n\tif cachedMapLoadRes != nil {\n\t\tres = cachedMapLoadRes\n\t} else {\n\t\tres, apiErr = api.Client.LoadContext(CurrentPlanId, CurrentBranch, loadContextReq)\n\t\tif apiErr != nil {\n\t\t\tonErr(fmt.Errorf(\"failed to load context: %v\", apiErr.Msg))\n\t\t}\n\t}\n\n\tterm.StopSpinner()\n\n\tif hasConflicts {\n\t\tterm.StartSpinner(\"🏗️  Starting build...\")\n\t\t_, err := buildPlanInlineFn(false, nil)\n\t\tif err != nil {\n\t\t\tonErr(fmt.Errorf(\"failed to build plan: %v\", err))\n\t\t}\n\t\tfmt.Println()\n\t}\n\n\tfmt.Println(\"✅ \" + res.Msg)\n\n\tif len(alreadyLoadedByComposite) > 0 {\n\t\tprintAlreadyLoadedMsg(alreadyLoadedByComposite)","sourceCodeStart":709,"sourceCodeEnd":745,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/lib/context_load.go#L709-L745","documentation":"MustLoadContext wraps the error message from api.Client.LoadContext when the server rejects or fails the context-load request for the current plan/branch. It means the API call itself failed (network, auth, server-side error), so no context was loaded. The wrapped apiErr.Msg carries the server-side reason.","triggerScenarios":"api.Client.LoadContext(CurrentPlanId, CurrentBranch, loadContextReq) returns a non-nil apiErr — server 4xx/5xx, expired session, unreachable API, or invalid loadContextReq entries.","commonSituations":"Expired or invalid API key; plan/branch deleted server-side; offline or proxy/DNS issues; requesting paths the server no longer recognizes after a repo rebase.","solutions":["Inspect apiErr.Msg for the server-side reason (auth vs validation vs 5xx)","Verify API connectivity and re-authenticate (log in again / refresh API key)","Confirm CurrentPlanId and CurrentBranch still exist, then retry the load"],"exampleFix":"// before\nres, apiErr = api.Client.LoadContext(CurrentPlanId, CurrentBranch, loadContextReq)\nif apiErr != nil {\n    onErr(fmt.Errorf(\"failed to load context: %v\", apiErr.Msg))\n}\n// after — distinguish auth from transient errors\nres, apiErr = api.Client.LoadContext(CurrentPlanId, CurrentBranch, loadContextReq)\nif apiErr != nil {\n    if apiErr.Code == 401 {\n        onErr(fmt.Errorf(\"session expired, please log in again: %v\", apiErr.Msg))\n    } else {\n        onErr(fmt.Errorf(\"failed to load context: %v\", apiErr.Msg))\n    }\n}","handlingStrategy":"retry","validationCode":"if CurrentPlanId == \"\" || CurrentBranch == \"\" {\n    return fmt.Errorf(\"no active plan/branch; select one before loading context\")\n}\nif err := checkApiReachable(); err != nil {\n    return fmt.Errorf(\"API unreachable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"res, apiErr := api.Client.LoadContext(planId, branch, req)\nif apiErr != nil {\n    if apiErr.Code == 401 || apiErr.Code == 403 {\n        // re-authenticate then retry once\n        reauth(); res, apiErr = api.Client.LoadContext(planId, branch, req)\n    }\n    if apiErr != nil { onErr(fmt.Errorf(\"failed to load context: %v\", apiErr.Msg)) }\n}","preventionTips":["Keep the session/API key fresh; re-login before long sessions","Confirm the plan/branch exists before scripted context loads","Check connectivity/proxy settings before batch operations"],"tags":["api","network","context"],"backgroundTag":"api-request-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}