workos-python icon indicating copy to clipboard operation
workos-python copied to clipboard

"allow_profiles_outside_organization is required" error when parsing Organization object

Open FilipAtScribe opened this issue 1 year ago • 7 comments

When sending an organization.created event (both a test event and a real one) an error is thrown: allow_profiles_outside_organization is required.

The field is marked as deprecated since version 4.12.0

FilipAtScribe avatar Sep 27 '24 12:09 FilipAtScribe

Hi @FilipAtScribe, thanks for your report. Could you confirm which version of the Python SDK you're using? Could you also clarify if you're experiencing this issue when receiving an organization.created webhook event, or when querying the events API?

mattgd avatar Sep 27 '24 14:09 mattgd

Hi @mattgd The version we're using is 5.4.1 and the issue arises when receiving a organization.created event i'm assuming the same happens on organization.deleted and organization.updated as we use from workos.types.organizations import Organization for parsing the response. Here is the class in the 5.4.1 version:

class Organization(OrganizationCommon):
    allow_profiles_outside_organization: bool
    domains: Sequence[OrganizationDomain]
    lookup_key: Optional[str] = None

FilipAtScribe avatar Sep 27 '24 15:09 FilipAtScribe

Thanks for those details. The Organization object returned via events is slightly leaner than what is returned via the organization APIs. If you're doing some separate type validation on your end, the type you're looking for when using events is from workos.types.organizations import OrganizationCommon. Could you take a look and see if you have any success with that?

Our goal is to keep event objects and API objects as unified as possible, but there is some drift between a handful of them.

mattgd avatar Sep 27 '24 18:09 mattgd

Same issue here.

@mattgd will this be updated in any future version so this parameter is optional in class? Either that or to update documentation to not show Organization object to use for webhooks.

mirzadelic avatar Sep 28 '24 10:09 mirzadelic

Hi @mirzadelic, thanks for your report. Do you have some example code for how you're handling the organization.created webhook event? I want to make sure we're testing this properly, and also are able to correctly update the docs to make this more clear.

The allow_profiles_outside_organization property is deprecated in the API and will eventually be entirely removed, but we'll see what adjustments need to be made in the meantime to clear this up.

mattgd avatar Sep 30 '24 13:09 mattgd

@mattgd using it as Organization(**data) where data is dict of values without allow_profiles_outside_organization. But if you check here: https://github.com/workos/workos-python/blob/main/workos/types/organizations/organization.py#L7 there is allow_profiles_outside_organization: bool, should be optional.

But I understand we can use OrganizationCommon in this case.

mirzadelic avatar Sep 30 '24 14:09 mirzadelic

Got it, thanks. The intended usage is to use the return data as-is, which is an OrganizationCommon object (from workos.types.organizations import OrganizationCommon). I can see how this is confusing from the API reference docs, which we can clarify.

mattgd avatar Sep 30 '24 14:09 mattgd