in workos 3.0.0, every list endpoint that has a dedicated *List wrapper type parses each item with the wrong from_map, so items come back empty and all their real fields are gone.
WorkOS.Page.from_map(body, data_key, cast_item, fetch_next) maps cast_item over each element of body[data_key], so cast_item has to be the element caster. A bunch of the generated list_* functions pass the collection caster instead.
WorkOS.OrganizationMembershipService.list_organization_memberships:
WorkOS.Page.from_map(body, "data", &WorkOS.UserOrganizationMembershipList.from_map/1, fetch_next)
That &UserOrganizationMembershipList.from_map/1 runs against each individual membership map. A single membership has no data/list_metadata keys, so every element comes out as:
%WorkOS.UserOrganizationMembershipList{object: "organization_membership", data: nil, list_metadata: nil}
and id / user_id / organization_id are dropped. Reading membership.organization_id then raises KeyError.
Same in WorkOS.UserManagement.list_users:
WorkOS.Page.from_map(body, "data", &WorkOS.UserList.from_map/1, fetch_next) # should be &WorkOS.User.from_map/1
Grepping the generated code, the callers passing a *List type are all wrong:
list_organization_memberships -> UserOrganizationMembershipList (should be UserOrganizationMembership)
list_users -> UserList (should be User)
list_invitations -> UserInviteList
list_user_api_keys -> UserApiKeyList
- group memberships ->
GroupList
The ones passing an element type (CORSOriginResponse, UserSessionsListItem, RedirectUri) parse fine, so this looks like a codegen bug: wherever a *List wrapper type exists, the generator wired the wrapper in place of the element type.
Repro: call any of the above with at least one result. Confirmed on 3.0.0 against a stubbed response.
Fix is per function, swap the collection caster for the element one.
in workos 3.0.0, every list endpoint that has a dedicated
*Listwrapper type parses each item with the wrongfrom_map, so items come back empty and all their real fields are gone.WorkOS.Page.from_map(body, data_key, cast_item, fetch_next)mapscast_itemover each element ofbody[data_key], socast_itemhas to be the element caster. A bunch of the generatedlist_*functions pass the collection caster instead.WorkOS.OrganizationMembershipService.list_organization_memberships:That
&UserOrganizationMembershipList.from_map/1runs against each individual membership map. A single membership has nodata/list_metadatakeys, so every element comes out as:and
id/user_id/organization_idare dropped. Readingmembership.organization_idthen raisesKeyError.Same in
WorkOS.UserManagement.list_users:Grepping the generated code, the callers passing a
*Listtype are all wrong:list_organization_memberships->UserOrganizationMembershipList(should beUserOrganizationMembership)list_users->UserList(should beUser)list_invitations->UserInviteListlist_user_api_keys->UserApiKeyListGroupListThe ones passing an element type (
CORSOriginResponse,UserSessionsListItem,RedirectUri) parse fine, so this looks like a codegen bug: wherever a*Listwrapper type exists, the generator wired the wrapper in place of the element type.Repro: call any of the above with at least one result. Confirmed on 3.0.0 against a stubbed response.
Fix is per function, swap the collection caster for the element one.