#1011·chat

replyUpdateUser computes the missing-credentials list only when GetAllCreds failed

Author: akiva1132Created Sep 3, 2026Updated Sep 5, 2026
Labelsbug

In replyUpdateUser (server/user.go, master at the time of writing):

go
if allCreds, err := store.Users.GetAllCreds(uid, "", true); err != nil {
	var validated []string
	for i := range allCreds {
		validated = append(validated, allCreds[i].Method)
	}
	_, missing, _ := stringSliceDelta(globals.authValidators[authLvl], validated)
	if len(missing) > 0 {
		params = map[string]any{"cred": missing}
	}
}

The condition is err != nil, so the body — which builds the list of credentials the account still lacks — runs only when GetAllCreds failed, and then over an empty allCreds. On the path that works nothing runs, params stays nil, and the {ctrl} answering a successful {acc cred:[...]} never carries cred.

Expected: err == nil, so the reply tells the client which required validators are still unconfirmed (the same list replyCreateUser returns after registration).

Reproduced with a unit test around Session.dispatch using the gomock store: with one validated tel credential and auth_validators requiring tel and email, the reply's params.cred is nil; with the condition flipped it is ["email"].