plandex-ai/plandex · error

error getting user permissions

Error message

error getting user permissions

What it means

After membership is confirmed, db.GetUserPermissions(authToken.UserId, parsed.OrgId) failed; the server logs 'error getting user permissions' and returns HTTP 500 when raiseErr is true. Backend failure loading the permission rows needed to build the request's permissions map.

Source

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

				return nil
			}

		} else {
			log.Println("user is not a member of the org")
			if raiseErr {
				http.Error(w, "not a member of org", http.StatusUnauthorized)
			}
			return nil
		}
	}

	// get user permissions
	permissions, err := db.GetUserPermissions(authToken.UserId, parsed.OrgId)

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

	// build the permissions map
	permissionsMap := make(shared.Permissions)
	for _, permission := range permissions {
		permissionsMap[permission] = true
	}

	auth := &types.ServerAuth{
		AuthToken:   authToken,
		User:        user,
		OrgId:       parsed.OrgId,
		Permissions: permissionsMap,
	}

	// don't send hash for org-session requests

View on GitHub (pinned to e2d772072e)

Solutions

  1. Check database health and inspect logs for the underlying GetUserPermissions error
  2. Verify permissions/roles schema is up to date with the current app version
  3. Retry the request once the DB is healthy
  4. Check that the user's role records exist for the org and backfill if missing
Defensive patterns

Strategy: retry

Try / catch

if err := doCall(ctx); err != nil {
	var apiErr *APIError
	if errors.As(err, &apiErr) && apiErr.StatusCode == 500 && strings.Contains(apiErr.Message, "user permissions") {
		return retryWithBackoff(ctx) // transient DB failure loading permissions
	}
	return err
}

Prevention

When it happens

Trigger: Authenticated, org-member request where the permissions query errors (DB down, timeout, schema mismatch in permissions/roles tables).

Common situations: Database outages or connection-pool exhaustion; role/permission schema migrations not applied; corrupt or missing role rows for the user-org pair.

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