plandex-ai/plandex · error

error fetching org roles: %s

Error message

error fetching org roles: %s

What it means

This error wraps a failure from api.Client.ListOrgRoles() in the users command's third parallel fetch goroutine. The *shared.ApiError Msg is interpolated into 'error fetching org roles: %s'. It means the org-role listing failed, so the users command cannot render role assignments.

Source

Thrown at app/cli/cmd/users.go:61

		}
		errCh <- nil
	}()

	go func() {
		var err *shared.ApiError
		pendingInvites, err = api.Client.ListPendingInvites()
		if err != nil {
			errCh <- fmt.Errorf("error fetching pending invites: %s", err.Msg)
			return
		}
		errCh <- nil
	}()

	go func() {
		var err *shared.ApiError
		orgRoles, err = api.Client.ListOrgRoles()
		if err != nil {
			errCh <- fmt.Errorf("error fetching org roles: %s", err.Msg)
			return
		}
		errCh <- nil

	}()

	for i := 0; i < 3; i++ {
		err := <-errCh
		if err != nil {
			term.StopSpinner()
			term.OutputErrorAndExit("%v", err)
		}
	}

	term.StopSpinner()

	orgRolesById := make(map[string]*shared.OrgRole)
	for _, role := range orgRoles {

View on GitHub (pinned to e2d772072e)

Solutions

  1. Re-authenticate to refresh credentials
  2. Confirm your role can list org roles (ask an admin if not)
  3. Check network/proxy connectivity to the API host
  4. Read the embedded err.Msg for the HTTP status and handle accordingly

Example fix

// before
errCh <- fmt.Errorf("error fetching org roles: %s", err.Msg)
// after
if err.Status == 403 {
	errCh <- fmt.Errorf("error fetching org roles: %s (insufficient permissions)", err.Msg)
} else {
	errCh <- fmt.Errorf("error fetching org roles: %s", err.Msg)
}
Defensive patterns

Strategy: type-guard

Validate before calling

// pre-flight: confirm the account can read org roles before invoking the command
if api.Client == nil || api.Client.Token == "" {
	return fmt.Errorf("not authenticated")
}
// optionally probe permission via a lighter endpoint first

Type guard

func isApiError(err error) (*shared.ApiError, bool) {
	ae, ok := err.(*shared.ApiError)
	return ae, ok
}

Try / catch

orgRoles, err := api.Client.ListOrgRoles()
if err != nil {
	if ae, ok := err.(*shared.ApiError); ok {
		if ae.Status == 403 {
			return fmt.Errorf("your role cannot list org roles; contact an admin")
		}
		if ae.Status == 401 {
			return reauthAndRetry()
		}
	}
	return fmt.Errorf("error fetching org roles: %w", err)
}

Prevention

When it happens

Trigger: ListOrgRoles() returning non-nil *shared.ApiError: invalid/expired credentials, insufficient permissions to list roles, network failure, or server 4xx/5xx response.

Common situations: Accounts without admin/role-read permissions; expired session tokens; API outages; proxy/firewall blocking requests.

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