Skip to content

Commit 736064d

Browse files
fix validator
1 parent 2af6c94 commit 736064d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/models-library/src/models_library/clusters.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,14 @@ class Cluster(BaseCluster):
221221
},
222222
)
223223

224-
@model_validator(mode="before")
224+
@model_validator(mode="after")
225225
@classmethod
226-
def check_owner_has_access_rights(cls, values):
227-
is_default_cluster = bool(values["id"] == DEFAULT_CLUSTER_ID)
228-
owner_gid = values["owner"]
226+
def _check_owner_has_access_rights(cls, values):
227+
is_default_cluster = bool(values.id == DEFAULT_CLUSTER_ID)
228+
owner_gid = values.owner
229229

230230
# check owner is in the access rights, if not add it
231-
access_rights = values.get("access_rights", values.get("accessRights", {}))
231+
access_rights = values.access_rights or {}
232232
if owner_gid not in access_rights:
233233
access_rights[owner_gid] = (
234234
CLUSTER_USER_RIGHTS if is_default_cluster else CLUSTER_ADMIN_RIGHTS
@@ -239,5 +239,5 @@ def check_owner_has_access_rights(cls, values):
239239
):
240240
msg = f"the cluster owner access rights are incorrectly set: {access_rights[owner_gid]}"
241241
raise ValueError(msg)
242-
values["access_rights"] = access_rights
242+
values.access_rights = access_rights
243243
return values

0 commit comments

Comments
 (0)