refactor: handle oauth groups response as an any array of any

This commit is contained in:
Stavros
2025-07-17 00:31:24 +03:00
parent 1a13936693
commit 19eb8f3064
2 changed files with 17 additions and 8 deletions

View File

@@ -330,12 +330,21 @@ func DeriveKey(secret string, info string) (string, error) {
func CoalesceToString(value any) string {
switch v := value.(type) {
case []string:
return strings.Join(v, ",")
case []any:
log.Debug().Msg("Coalescing []any to string")
strs := make([]string, 0, len(v))
for _, item := range v {
if str, ok := item.(string); ok {
strs = append(strs, str)
continue
}
log.Warn().Interface("item", item).Msg("Item in []any is not a string, skipping")
}
return strings.Join(strs, ",")
case string:
return v
default:
log.Warn().Interface("value", value).Msg("Unsupported type, returning empty string")
log.Warn().Interface("value", value).Interface("type", v).Msg("Unsupported type, returning empty string")
return ""
}
}