{"record":{"id":"1c722d3d118e74f3","repo":"plandex-ai/plandex","slug":"error-getting-context-body-v","errorCode":null,"errorMessage":"error getting context body: %v","messagePattern":"error getting context body: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/cmd/context_show.go","lineNumber":63,"sourceCode":"\t\t} else {\n\t\t\t// Try finding by name\n\t\t\tfound := false\n\t\t\tfor _, ctx := range contexts {\n\t\t\t\tif ctx.Name == nameOrIndex || ctx.FilePath == nameOrIndex {\n\t\t\t\t\tcontextId = ctx.Id\n\t\t\t\t\tfound = true\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !found {\n\t\t\t\treturn fmt.Errorf(\"no context found with name: %s\", nameOrIndex)\n\t\t\t}\n\t\t}\n\n\t\tres, apiErr := api.Client.GetContextBody(lib.CurrentPlanId, lib.CurrentBranch, contextId)\n\t\tif apiErr != nil {\n\t\t\tlog.Printf(\"Error getting context body: %v\\n\", apiErr)\n\t\t\treturn fmt.Errorf(\"error getting context body: %v\", apiErr)\n\t\t}\n\n\t\tfmt.Println(res.Body)\n\t\treturn nil\n\t},\n}\n","sourceCodeStart":45,"sourceCodeEnd":70,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/cmd/context_show.go#L45-L70","documentation":"After the context is resolved to an ID, the command calls api.Client.GetContextBody(planId, branch, contextId) to fetch the context's stored body. If that API call returns an error, the CLI logs it and returns 'error getting context body: %v'. The context exists locally in the list, but its content could not be retrieved from the server — typically a network/server/auth problem or the context being deleted concurrently.","triggerScenarios":"The resolved contextId is stale (context deleted server-side between list and fetch), the server returns 404 for the context, or the GetContextBody HTTP request fails due to connectivity, expired auth, or a server 5xx.","commonSituations":"Another session/machine removed the context after you listed them; daemon restarted or connection dropped mid-command; session token expired; server database issue returning 500.","solutions":["Re-run `plandex contexts show` — if the context was deleted, it will now fail at listing/lookup, which tells you the context is gone.","Check the logged 'Error getting context body' line for the underlying HTTP status and fix accordingly (re-auth for 401, reload for 404).","Verify server connectivity and that the Plandex daemon is running; retry once connectivity is restored.","If the context was deleted or its body lost, re-load the source file with `plandex load <file>`."],"exampleFix":"// before\nres, apiErr := api.Client.GetContextBody(lib.CurrentPlanId, lib.CurrentBranch, contextId)\nif apiErr != nil {\n  return fmt.Errorf(\"error getting context body: %v\", apiErr)\n}\n// after\nres, apiErr := api.Client.GetContextBody(lib.CurrentPlanId, lib.CurrentBranch, contextId)\nif apiErr != nil {\n  if apiErr.Status == 404 {\n    return fmt.Errorf(\"context %q no longer exists on server; re-load it with 'plandex load'\", contextId)\n  }\n  return fmt.Errorf(\"getting context body failed (HTTP %d): %s\", apiErr.Status, apiErr.Msg)\n}","handlingStrategy":"retry","validationCode":"// re-list and confirm the context still exists before fetching its body\nfresh, err := api.Client.ListContext(planId, branch)\nif err == nil {\n    exists := false\n    for _, c := range fresh {\n        if c.Id == contextId { exists = true; break }\n    }\n    if !exists {\n        return fmt.Errorf(\"context %s no longer exists; re-load it\", contextId)\n    }\n}","typeGuard":"func isNotFound(err *shared.ApiError) bool {\n    return err != nil && err.Status == 404\n}","tryCatchPattern":"res, apiErr := api.Client.GetContextBody(planId, branch, contextId)\nif apiErr != nil {\n    if isNotFound(apiErr) {\n        return fmt.Errorf(\"context deleted server-side; re-load with 'plandex load'\")\n    }\n    if apiErr.Status >= 500 || apiErr.Status == 0 {\n        // transient: retry with backoff\n    }\n    return apiErr\n}","preventionTips":["Fetch the body promptly after resolving the ID to avoid racing concurrent deletions","Retry transient (network/5xx) failures with backoff before surfacing the error","Treat 404 as 'context removed' and fall back to re-loading the source file","Keep auth fresh so long-running scripts don't fail on expired sessions"],"tags":["cli","network","api","go"],"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-14T00:17:10.932Z"}