plandex-ai/plandex · error

error validating org membership

Error message

error validating org membership

What it means

db.ValidateOrgMembership(authToken.UserId, parsed.OrgId) returned an error, so execAuthenticate logs 'error validating org membership' and responds HTTP 500 when raiseErr is true. This is a backend/database failure while checking membership — distinct from the user simply not being a member.

Source

Thrown at app/server/handlers/auth_helpers.go:529

			User:      user,
		}
	}

	if parsed.OrgId == "" {
		log.Println("no org id")
		if raiseErr {
			http.Error(w, "no org id", http.StatusUnauthorized)
		}
		return nil
	}

	// validate the org membership
	isMember, err := db.ValidateOrgMembership(authToken.UserId, parsed.OrgId)

	if err != nil {
		log.Printf("error validating org membership: %v\n", err)
		if raiseErr {
			http.Error(w, "error validating org membership", http.StatusInternalServerError)
		}
		return nil
	}

	if !isMember {
		// check if there's an invite for this user and accept it if so (adds the user to the org)
		invite, err := db.GetActiveInviteByEmail(parsed.OrgId, user.Email)

		if err != nil {
			log.Printf("error getting invite for org user: %v\n", err)
			if raiseErr {
				http.Error(w, "error getting invite for org user", http.StatusInternalServerError)
			}
			return nil
		}

		if invite != nil {
			log.Println("accepting invite")

View on GitHub (pinned to e2d772072e)

Solutions

  1. Check database health and retry the request
  2. Inspect server logs for the underlying error from db.ValidateOrgMembership
  3. Verify the org_memberships table/schema matches the current app version
  4. Add idempotent retry/backoff on transient DB failures
Defensive patterns

Strategy: retry

Try / catch

err := retry.WithBackoff(ctx, 3, func() error {
	_, err := client.OrgResource(ctx, orgID)
	var apiErr *APIError
	if errors.As(err, &apiErr) && apiErr.StatusCode == 500 && strings.Contains(apiErr.Message, "org membership") {
		return err // transient DB issue, retry
	}
	return nil // non-retryable
})

Prevention

When it happens

Trigger: Database errors (connection failure, timeout, bad query) during the membership lookup for an authenticated request with an OrgId.

Common situations: DB outages or connection-pool exhaustion; schema drift between app version and database; transient network issues between app and database.

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/aab6bc00af949ec1. Report an issue: GitHub.