-
Notifications
You must be signed in to change notification settings - Fork 37
Description
Hello,
I’m testing the SDK after upgrading from 1.8.0 to 3.0.2, and I’ve observed that calling clerk.get_organization_memberships for users whose Role has no Permissions results in a pydantic_core._pydantic_core.ValidationError.
From the traceback, it appears that the error is caused by a mismatch in the OrganizationMembership Pydantic model definition introduced in v2.0.0:
- Up through 1.8.0
class OrganizationMembership(BaseModel):
...
permissions: Optional[List[str]] # Allows Roles without any Permissions
...- Since 2.0.0
class OrganizationMembership(BaseModel):
...
permissions: List[str] # No longer allows Roles without Permissions
...While I understand the intention behind making permissions non-optional, the Clerk Dashboard itself still allows Roles without any Permissions. This inconsistency means that any organization using permission-less Roles will encounter runtime validation errors when fetching memberships via the SDK.
Recommended solutions:
- Disallow permission-less Roles in the Clerk Dashboard, or
- Rollback the SDK model change so that permissions remains optional.
For reference, please see the full traceback below:
Traceback (most recent call last):
File "lib/python3.12/site-packages/clerk_backend_api/users.py", line 3431, in get_organization_memberships_async
return utils.unmarshal_json(
^^^^^^^^^^^^^^^^^^^^^
File "lib/python3.12/site-packages/clerk_backend_api/utils/serializers.py", line 140, in unmarshal_json
return unmarshal(from_json(raw), typ)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "lib/python3.12/site-packages/clerk_backend_api/utils/serializers.py", line 150, in unmarshal
m = unmarshaller(body=val)
^^^^^^^^^^^^^^^^^^^^^^
File "lib/python3.12/site-packages/pydantic/main.py", line 253, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for Unmarshaller
body.data.0.permissions
Input should be a valid list [type=list_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.11/v/list_type
I hope this issue can be resolved quickly.
Thank you!