From fb44d547d7da8bc66e73ca5a0dae075d77e79ddd Mon Sep 17 00:00:00 2001 From: Tyler Allen Date: Wed, 28 Jan 2026 20:39:11 -0500 Subject: [PATCH] Recover safely from users without slackUID (#63) * if slackuid doesn't exist, notify * add logrus Fields --- users.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/users.go b/users.go index a3d10f4..d20a390 100644 --- a/users.go +++ b/users.go @@ -133,10 +133,15 @@ func (client *OIDCClient) GetUserInfo(user *OIDCUser) { return } if len(arg) > 0 { - userData := make([]map[string]interface{}, 0) + userData := make([]map[string]any, 0) err = json.Unmarshal(b, &userData) // userdata attributes are a KV pair of string:[]any, this casts attributes, finds the specific attribute, casts it to a list of any, and then pulls the first field since there will only ever be one - user.SlackUID = userData[0]["attributes"].(map[string]interface{})["slackuid"].([]interface{})[0].(string) + userAttributes := userData[0]["attributes"].(map[string]any) + if slackIDRaw, exists := userAttributes["slackuid"]; exists { + user.SlackUID = slackIDRaw.([]any)[0].(string) + } else { + logging.Logger.WithFields(logrus.Fields{"method": "GetUserInfo"}).Error("User " + user.Username + " does not have a SlackUID. Skipping messaging.") + } } else { err = json.Unmarshal(b, &user) }