plandex-ai/plandex · warning

No plans found

Error message

No plans found

What it means

A 404 returned by GetCurrentBranchByPlanIdHandler when ListOwnedPlans succeeds but returns zero plans for the given projectId and authenticated user. The endpoint only works for projects that contain at least one plan owned by the caller.

Source

Thrown at app/server/handlers/plans_crud.go:609

	var req shared.GetCurrentBranchByPlanIdRequest
	if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
		log.Printf("Error parsing request body: %v\n", err)
		http.Error(w, "Error parsing request body", http.StatusBadRequest)
		return
	}

	plans, err := db.ListOwnedPlans([]string{projectId}, auth.User.Id, false)

	if err != nil {
		log.Printf("Error listing plans: %v\n", err)
		http.Error(w, "Error listing plans: "+err.Error(), http.StatusInternalServerError)
		return
	}

	if len(plans) == 0 {
		log.Println("No plans found")
		http.Error(w, "No plans found", http.StatusNotFound)
		return
	}

	query := "SELECT * FROM branches WHERE "

	var orConditions []string
	var queryArgs []interface{}
	currentArg := 1
	for _, plan := range plans {
		branchName, ok := req.CurrentBranchByPlanId[plan.Id]

		if !ok {
			continue
		}

		orConditions = append(orConditions, fmt.Sprintf("(plan_id = $%d AND name = $%d)", currentArg, currentArg+1))
		queryArgs = append(queryArgs, plan.Id, branchName)

View on GitHub (pinned to e2d772072e)

Solutions

  1. Confirm the projectId is correct and belongs to the authenticated user's org
  2. List plans in the project first (plandex plans / list plans endpoint) to verify any exist
  3. Check you are authenticated as the plan owner (ListOwnedPlans filters by user id)
  4. Recreate a plan in the project if it was deleted
Defensive patterns

Strategy: validation

Validate before calling

const plans = await listPlans(projectId);
if (!plans || plans.length === 0) {
  throw new Error(`No plans in project ${projectId}; skipping current-branch lookup`);
}

Type guard

function hasPlans(result) {
  return Array.isArray(result) && result.length > 0;
}

Try / catch

try {
  const res = await api.getCurrentBranchByPlanId(projectId, body);
} catch (err) {
  if (err.status === 404 && err.message === 'No plans found') {
    console.warn(`Project ${projectId} has no plans for this user; create one first`);
    return null;
  }
  throw err;
}

Prevention

When it happens

Trigger: Calling the current-branch endpoint with a projectId that has no plans, using an API token belonging to a different user/organization than the project owner, or after all plans in the project were deleted.

Common situations: Copy-pasting a projectId from another account; plans deleted or archived elsewhere; stale CLI config pointing at the wrong server/org; freshly created project with no plans yet.

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


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