plandex-ai/plandex · error

error validating project membership: %v

Error message

error validating project membership: %v

What it means

After loading the plan, ValidatePlanAccess checks that the plan's project exists under the given org by calling ProjectExists. If that COUNT query errors, it is wrapped with this message — signaling the membership/access check itself could not be performed, not that access was denied.

Source

Thrown at app/server/db/plan_helpers.go:467

	// get plan
	plan, err := GetPlan(planId)

	if err != nil {
		return nil, fmt.Errorf("error getting plan: %v", err)
	}

	if plan == nil {
		return nil, nil
	}

	if plan.OrgId != orgId {
		return nil, nil
	}

	hasProjectAccess, err := ProjectExists(orgId, plan.ProjectId)

	if err != nil {
		return nil, fmt.Errorf("error validating project membership: %v", err)
	}

	if !hasProjectAccess {
		return nil, nil
	}

	// owner has access
	if plan.OwnerId == userId {
		return plan, nil
	}

	// plan is shared with org
	if plan.SharedWithOrgAt != nil {
		return plan, nil
	}

	return nil, nil
}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Inspect the wrapped inner error for the root DB cause
  2. Check DB connectivity and the projects table schema (org_id, id columns)
  3. Verify plan.ProjectId is not empty/corrupted in the plans table
  4. Retry the request if the failure was transient (e.g. connection pool exhaustion)
Defensive patterns

Strategy: try-catch

Validate before calling

if plan.ProjectId == "" {
    return errors.New("plan has no associated project; cannot validate membership")
}

Try / catch

hasAccess, err := ProjectExists(orgId, plan.ProjectId)
if err != nil {
    return fmt.Errorf("membership check failed: %w", err)
}
if !hasAccess {
    return ErrForbidden
}

Prevention

When it happens

Trigger: ProjectExists(orgId, plan.ProjectId) fails — DB connectivity issue, scan failure, or the projects table is unavailable/unqueryable while validating plan access.

Common situations: Transient DB outages during authorization, plan rows referencing a project_id in an inconsistent state after partial deletes, schema mismatches on the projects table.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


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