mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-18 03:15:11 +00:00
fix: correctly unmarshal login names and metadata in user repository (#11775)
## Problem description When calling `repository.UserRepository().Get(...)` the following error got returned caused by scanning. `Scan error: scanning: doing scan: scanFn: scany: scan row into struct fields: sql: Scan error on column index 7, name "metadata": unsupported Scan, storing driver.Value type []uint8 into type *[]*domain.Metadata` ## How the problem got solved The issue was that json arrays were not properly unmarshalled during scanning the rows into structs. ## Additional changes The issue could also happen on login names, therefore it got fixed for this field too. Other fields are not affected because we use `json.RawMessage` for the specific user types. ## Additional information Introduced in https://github.com/zitadel/zitadel/pull/10967
This commit is contained in:
@@ -351,8 +351,10 @@ func (u user) organizationIDColumn() database.Column {
|
||||
|
||||
type rawUser struct {
|
||||
domain.User
|
||||
Machine *json.RawMessage `json:"machine,omitempty" db:"machine"`
|
||||
Human *json.RawMessage `json:"human,omitempty" db:"human"`
|
||||
Machine *json.RawMessage `json:"machine,omitempty" db:"machine"`
|
||||
Human *json.RawMessage `json:"human,omitempty" db:"human"`
|
||||
LoginNames JSONArray[domain.LoginName] `json:"loginNames,omitempty" db:"login_names"`
|
||||
Metadata JSONArray[*domain.Metadata] `json:"metadata,omitempty" db:"metadata"`
|
||||
}
|
||||
|
||||
func (u *rawUser) toDomain() (*domain.User, error) {
|
||||
@@ -367,6 +369,8 @@ func (u *rawUser) toDomain() (*domain.User, error) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
u.User.LoginNames = u.LoginNames
|
||||
u.User.Metadata = u.Metadata
|
||||
return &u.User, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user