Skip to content

users.get_billing_subscription() does not return the user's subscription plan #195

@mlvieras

Description

@mlvieras

After upgrading to 4.0.0 I found that users.get_billing_subscription() was not returning the user's subscription plan under subscription_items. Upon looking at the documentation and the code I think that this is a bug.

Here's a small example that reproduces the issue:

clerk = Clerk(CLERK_SECRET_KEY)
user_id = 'XXXXXXXXXXXXXXXXXXXXXXX'
subscription = clerk.users.get_billing_subscription(user_id=user_id)
print(subscription.subscription_items[0].plan) # Prints nothing
print(type(subscription.subscription_items[0].plan)) # Returns `<class 'clerk_backend_api.types.basemodel.Unset'>`

Please note that you need to call this with a user that has subscribed to a plan.

I'm not really familiar with Pydantic but I think this is caused by the FeatureResponse model being too restrictive. It expects the avatar_url field to be a string but in my project none of the features have avatars, and so their value is null. I fixed this by changing the type definition to Optional[str] here.

I think this needs to be fixed at the documentation level since the docs clearly show that avatar_url is required as a string.

Image

Thanks for looking into this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions