Skip to content

list_users is broken after last fix #519

@barp

Description

@barp

After closing #511 a new bug appeared:
Although now list_users correctly set the list_params such that it can be passed by the paging function to be able to retrieve the next page, it is now incorrectly uses incorrect paramteres to the back end.

    def list_users(
        self,
        *,
        directory_id: Optional[str] = None,
        group_id: Optional[str] = None,
        limit: int = DEFAULT_LIST_RESPONSE_LIMIT,
        before: Optional[str] = None,
        after: Optional[str] = None,
        order: PaginationOrder = "desc",
    ) -> DirectoryUsersListResource:
        list_params: DirectoryUserListFilters = {
            "limit": limit,
            "before": before,
            "after": after,
            "order": order,
        }

        if group_id is not None:
            list_params["group_id"] = group_id
        if directory_id is not None:
            list_params["directory_id"] = directory_id

        response = self._http_client.request(
            "directory_users",
            method=REQUEST_METHOD_GET,
            params=list_params,
        )

        return WorkOSListResource(
            list_method=self.list_users,
            list_args=list_params,
            **ListPage[DirectoryUserWithGroups](**response).model_dump(),
        )

now the code throws:

workos.exceptions.BadRequestException: (message=Validation failed, request_id=82c3dcfe-236f-43bf-985e-05598eeea99d, errors=[{'field': 'directory_id', 'code': 'property directory_id should not exist'}, {'field': 'directory', 'code': 'Please provide either "directory" or "group" parameters.'}, {'field': 'group', 'code': 'Please provide either "directory" or "group" parameters.'}])

WorkOSListResource expects list_params to use group_id and directory_id, but the API expects directory and group it seems.

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