plandex-ai/plandex · error

error getting context body: %v

Error message

error getting context body: %v

What it means

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.

Source

Thrown at app/cli/cmd/context_show.go:63

		} else {
			// Try finding by name
			found := false
			for _, ctx := range contexts {
				if ctx.Name == nameOrIndex || ctx.FilePath == nameOrIndex {
					contextId = ctx.Id
					found = true
					break
				}
			}
			if !found {
				return fmt.Errorf("no context found with name: %s", nameOrIndex)
			}
		}

		res, apiErr := api.Client.GetContextBody(lib.CurrentPlanId, lib.CurrentBranch, contextId)
		if apiErr != nil {
			log.Printf("Error getting context body: %v\n", apiErr)
			return fmt.Errorf("error getting context body: %v", apiErr)
		}

		fmt.Println(res.Body)
		return nil
	},
}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Re-run `plandex contexts show` — if the context was deleted, it will now fail at listing/lookup, which tells you the context is gone.
  2. Check the logged 'Error getting context body' line for the underlying HTTP status and fix accordingly (re-auth for 401, reload for 404).
  3. Verify server connectivity and that the Plandex daemon is running; retry once connectivity is restored.
  4. If the context was deleted or its body lost, re-load the source file with `plandex load <file>`.

Example fix

// before
res, apiErr := api.Client.GetContextBody(lib.CurrentPlanId, lib.CurrentBranch, contextId)
if apiErr != nil {
  return fmt.Errorf("error getting context body: %v", apiErr)
}
// after
res, apiErr := api.Client.GetContextBody(lib.CurrentPlanId, lib.CurrentBranch, contextId)
if apiErr != nil {
  if apiErr.Status == 404 {
    return fmt.Errorf("context %q no longer exists on server; re-load it with 'plandex load'", contextId)
  }
  return fmt.Errorf("getting context body failed (HTTP %d): %s", apiErr.Status, apiErr.Msg)
}
Defensive patterns

Strategy: retry

Validate before calling

// re-list and confirm the context still exists before fetching its body
fresh, err := api.Client.ListContext(planId, branch)
if err == nil {
    exists := false
    for _, c := range fresh {
        if c.Id == contextId { exists = true; break }
    }
    if !exists {
        return fmt.Errorf("context %s no longer exists; re-load it", contextId)
    }
}

Type guard

func isNotFound(err *shared.ApiError) bool {
    return err != nil && err.Status == 404
}

Try / catch

res, apiErr := api.Client.GetContextBody(planId, branch, contextId)
if apiErr != nil {
    if isNotFound(apiErr) {
        return fmt.Errorf("context deleted server-side; re-load with 'plandex load'")
    }
    if apiErr.Status >= 500 || apiErr.Status == 0 {
        // transient: retry with backoff
    }
    return apiErr
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


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