bytebase/bytebase · error
failed to batch get users by emails
Error message
failed to batch get users by emails
What it means
Wraps a store failure in countUsersInIamPolicy when BatchGetUsersByEmails fails while resolving principals' deleted state for seat counting. Used by server info, password-reset checks, and IAM policy updates; means the seat count could not be computed.
Source
Thrown at backend/api/v1/user_service.go:1593
members, _ := s.GetGroupMembersSnapshot(ctx, workspaceID, "groups/"+ref)
for member := range members {
if strings.HasPrefix(member, "users/") {
emails[strings.ToLower(strings.TrimPrefix(member, "users/"))] = struct{}{}
}
}
}
if len(emails) == 0 {
return 0, nil
}
emailList := make([]string, 0, len(emails))
for email := range emails {
emailList = append(emailList, email)
}
// Pass an empty workspace to look up principals by email only: the seat set is
// already derived from policy, we just need each principal's deleted state.
users, err := s.BatchGetUsersByEmails(ctx, "", emailList)
if err != nil {
return 0, errors.Wrapf(err, "failed to batch get users by emails")
}
deleted := 0
for _, user := range users {
if user.MemberDeleted {
if _, ok := emails[user.Email]; ok {
deleted++
}
}
}
return len(emails) - deleted, nil
}
// userCountGuard checks seat limits before adding a new IAM member (e.g. SSO login).
// Uses >= because the new user has not been counted yet.
// If policy is nil, reads the current workspace IAM policy.
func userCountGuard(ctx context.Context, s *store.Store, licenseService *enterprise.LicenseService, workspaceID string, policy *storepb.IamPolicy, saas bool) error {
if policy == nil {
p, err := s.GetWorkspaceIamPolicy(ctx, workspaceID)View on GitHub (pinned to 1870550677)
Solutions
- Retry the operation
- Check metadata DB health
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at backend/api/v1/user_service.go:1593 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of bytebase/bytebase@1870550677 (2026-09-06).
Data as JSON: /api/errors/1a37d2c467d6d291.
Report an issue: GitHub.