mattermost-community/focalboard · error

no user ID

Error message

no user ID

What it means

GetUser returns this error when called with an empty user ID string. The App layer guards before querying the store, since GetUserByID cannot resolve an empty identifier. It is a caller-input validation error, not a data problem.

Source

Thrown at server/app/auth.go:57

	return a.store.GetActiveUserCount(secondsAgo)
}

// GetWeeklyActiveUsers returns the number of weekly active users.
func (a *App) GetWeeklyActiveUsers() (int, error) {
	secondsAgo := int64(SecondsPerMinute * MinutesPerHour * HoursPerDay * DaysPerWeek)
	return a.store.GetActiveUserCount(secondsAgo)
}

// GetMonthlyActiveUsers returns the number of monthly active users.
func (a *App) GetMonthlyActiveUsers() (int, error) {
	secondsAgo := int64(SecondsPerMinute * MinutesPerHour * HoursPerDay * DaysPerMonth)
	return a.store.GetActiveUserCount(secondsAgo)
}

// GetUser gets an existing active user by id.
func (a *App) GetUser(id string) (*model.User, error) {
	if len(id) < 1 {
		return nil, errors.New("no user ID")
	}

	user, err := a.store.GetUserByID(id)
	if err != nil {
		return nil, errors.Wrap(err, "unable to find user")
	}
	return user, nil
}

func (a *App) GetUsersList(userIDs []string) ([]*model.User, error) {
	if len(userIDs) == 0 {
		return nil, errors.New("No User IDs")
	}

	users, err := a.store.GetUsersList(userIDs, a.config.ShowEmailAddress, a.config.ShowFullName)
	if err != nil {
		return nil, errors.Wrap(err, "unable to find users")
	}

View on GitHub (pinned to a84bbb65e3)

Solutions

  1. Validate len(id) > 0 before calling GetUser
  2. Fix the data source so user IDs are populated before import
  3. Skip or substitute users with missing IDs during import

Example fix

// before
user, _ := app.GetUser(idFromJSON)
// after
if idFromJSON == "" {
    return errors.New("import record missing user id")
}
user, err := app.GetUser(idFromJSON)
Defensive patterns

Strategy: validation

Validate before calling

if id == "" {
    return nil, errors.New("cannot look up user: id is empty")
}

Type guard

func hasUserID(id string) bool { return strings.TrimSpace(id) != "" }

Try / catch

user, err := a.GetUser(id)
if err != nil {
    if err.Error() == "no user ID" {
        return fmt.Errorf("skipping: no user id provided")
    }
    return errors.Wrap(err, "get user failed")
}

Prevention

When it happens

Trigger: Calling a.GetUser("") — e.g. ImportBoardJSONL resolving a user ID that came back as an empty string from parsed JSONL fields.

Common situations: Board/user JSON imports with missing or blank owner/user id fields; unchecked string fields from webhook or API payloads used directly as user IDs.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


AI-assisted analysis of mattermost-community/focalboard@a84bbb65e3 (2026-08-30). Data as JSON: /api/errors/8bfa8ea5fba24227. Report an issue: GitHub.