bytebase/bytebase · warning

failed to get user id by email %v

Error message

failed to get user id by email %v

What it means

When sending a direct message, the plugin resolves each mentioned end user's WeCom user ID from their email via getUserIDByEmail. This error wraps any per-user lookup failure and is accumulated into a multierror; the DM to that user is skipped. It indicates the email could not be mapped to a WeCom user (API error, user not in the workspace, or email mismatch).

Source

Thrown at backend/plugin/webhook/wecom/wecom.go:171

	wecom := getWecomConfig(webhookCtx.IMSetting)
	if wecom == nil {
		return false
	}
	p, err := newProvider(wecom.GetCorpId(), wecom.GetAgentId(), wecom.GetSecret())
	if err != nil {
		slog.Error("failed to get wecom provider", log.BBError(err))
	}

	ctx := context.Background()

	fn := func() error {
		var errs error
		var users []string

		for _, u := range webhookCtx.MentionEndUsers {
			userID, err := p.getUserIDByEmail(ctx, u.Email)
			if err != nil {
				err = errors.Wrapf(err, "failed to get user id by email %v", u.Email)
				multierr.AppendInto(&errs, err)
				continue
			}
			users = append(users, userID)
		}
		if len(users) == 0 {
			err := errors.Errorf("wecom dm: got 0 user id, errs: %v", errs)
			return backoff.Permanent(err)
		}

		if err := p.sendMessage(ctx, users, getMessageCard(webhookCtx)); err != nil {
			err = errors.Wrapf(err, "failed to send message")
			multierr.AppendInto(&errs, err)
		}

		return errs
	}

View on GitHub (pinned to 1870550677)

Solutions

  1. Compare the Bytebase user email with the email configured in WeCom contacts — they must match exactly.
  2. Confirm the user still exists and is active in the WeCom workspace.
  3. Check WeCom contact-API permissions for the credentials used by the plugin.
  4. Retry — the accumulated multierror means other users may still have been notified.
  5. Exclude or update stale user records in MentionEndUsers.

Example fix

// ensure emails match before sending
mentionUsers := users.filter(u => wecomEmailExists(u.email))
Defensive patterns

Strategy: validation

Validate before calling

// ensure emails are set and normalized before triggering the webhook
for _, u := range mentionEndUsers {
    if u.Email == "" { continue /* or fix user record */ }
    u.Email = strings.ToLower(strings.TrimSpace(u.Email))
}

Try / catch

if err := p.Post(ctx, webhookCtx); err != nil {
    if strings.Contains(err.Error(), "failed to get user id by email") {
        // fix that user's email in Bytebase or WeCom; other users were still notified
    }
}

Prevention

When it happens

Trigger: Post with webhookCtx.MentionEndUsers containing a user whose getUserIDByEmail call fails — user not found in the WeCom workspace, API rejection, or network failure during lookup.

Common situations: Bytebase user email differs from the email registered in WeCom; user left the company/WeCom workspace; WeCom API credentials lacking permission to look up contacts; transient API failures.

Understand the failure class

Background: "User not found", "Invalid user", and "does not exist": what missing-user lookup errors mean across Rocket.Chat, LiteLLM, Phabricator, rustfs, and pnpm — this error's family across 10 libraries.

Related errors


AI-assisted analysis of bytebase/bytebase@1870550677 (2026-09-06). Data as JSON: /api/errors/49318b966b8c130f. Report an issue: GitHub.