bytebase/bytebase · error

failed to find user identity

Error message

failed to find user identity

What it means

This error wraps a failure from store.GetAccountByEmail: the account lookup itself errored (as opposed to returning no row). The library distinguishes lookup errors from 'not found' so callers know the query failed rather than the user being absent.

Source

Thrown at backend/component/recovery/service.go:391

	// without this, the operator hands over a password that Login keeps
	// refusing with ResourceExhausted until the window lapses.
	if err := s.store.ClearLoginAttempt(ctx, email, storepb.LoginAttemptKind_PASSWORD); err != nil {
		if result.Changed {
			return result, errors.Wrap(err, "password was reset, but failed to clear the login attempt counter")
		}
		return result, errors.Wrap(err, "failed to clear the login attempt counter")
	}

	if err := s.createAuditLog(ctx, request.WorkspaceID, resetUserPasswordAuditMethod, string(auditRequest)); err != nil {
		return result, errors.Wrap(err, "user password reset completed, but failed to create the recovery audit log")
	}
	return result, nil
}

func (s *Service) getActiveEndUser(ctx context.Context, email string) (*store.UserMessage, error) {
	account, err := s.store.GetAccountByEmail(ctx, email)
	if err != nil {
		return nil, errors.Wrap(err, "failed to find user identity")
	}
	if account == nil {
		return nil, errors.Errorf("user %q does not exist", email)
	}
	if account.Type != storepb.PrincipalType_END_USER || account.MemberDeleted {
		return nil, errors.Errorf("user %q is not an active end user", email)
	}
	user, err := s.store.GetUserByEmail(ctx, email)
	if err != nil {
		return nil, errors.Wrap(err, "failed to load user identity")
	}
	if user == nil || user.MemberDeleted {
		return nil, errors.Errorf("user %q is not an active end user", email)
	}
	return user, nil
}

func (s *Service) requireWorkspace(ctx context.Context, workspaceID string) error {

View on GitHub (pinned to 1870550677)

Solutions

  1. Check the wrapped cause for the actual database error and verify the metadata database connection (PG_URL) is correct and reachable.
  2. Retry the operation if the cause is transient (connection reset, timeout).
  3. Confirm the account/user tables exist and migrations have run (LATEST.sql applied).
  4. Validate the email argument is well-formed before calling the recovery APIs.

Example fix

// before
account, err := s.store.GetAccountByEmail(ctx, email)
if err != nil {
	return nil, errors.Wrap(err, "failed to find user identity")
}
// after
if email == "" {
	return nil, errors.New("email is required")
}
account, err := s.store.GetAccountByEmail(ctx, email)
if err != nil {
	if isTransientDBError(err) {
		return nil, retry.Wrap(err)
	}
	return nil, errors.Wrap(err, "failed to find user identity")
}
Defensive patterns

Strategy: validation

Validate before calling

if email == "" || !strings.Contains(email, "@") {
	return errors.New("a valid email is required")
}
if err := db.PingContext(ctx); err != nil {
	return fmt.Errorf("metadata DB unreachable: %w", err)
}

Try / catch

user, err := svc.getActiveEndUser(ctx, email)
var dbErr *store.DBError
if errors.As(err, &dbErr) {
	// transient: retry with backoff
	return retryWithBackoff(func() error { _, err = svc.getActiveEndUser(ctx, email); return err })
}

Prevention

When it happens

Trigger: getActiveEndUser calls s.store.GetAccountByEmail(ctx, email) and it returns err != nil — e.g. metadata database connectivity failure, query timeout, or SQL error — while resolving a user in AddUserToWorkspace or ResetUserPassword.

Common situations: Metadata database outage or misconfigured PG_URL during password recovery; transient network blips between the app and Postgres; malformed email input causing an unusual query path.

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 bytebase/bytebase@1870550677 (2026-09-06). Data as JSON: /api/errors/324eb9bc6f07782a. Report an issue: GitHub.