Skip to content

[ISSUE] LegacyZIAClient.zia.url_categories.list_categories() does not properly handle pagination params #418

@CKroes97

Description

@CKroes97

Description
When trying to retrieve all URL categories using LegacyZIAClient.zia.url_categories.list_categories(), we run into the following issues:

  • page_size is ignored, resulting in always all categories being returned
  • response.next does not result into the next page being retrieved but instead the same page is being retrieved over and er over again

Reproduction
A minimal code sample demonstrating the bug.

def client_get_all(func: callable, page_size: int) -> dict:
    """
    Retrieve all paginated records from a ZIA API function.

    Args:
        func (callable): ZIA client function to call.
        page_size (int): Number of items per page.

    Returns:
        dict: List of all items retrieved.
    """
    items, response, error = func(query_params={"page_size": page_size})
    print(f"Loaded first page with {len(items)} items", flush=True)
    if error:
        raise Exception(f"Error retrieving page: {error}")

    while response.has_next():
        next_page, response, error = response.next()
        if error:
            raise Exception(f"Error retrieving page: {error}")
        if next_page:
            print(f"Loaded next page with {len(next_page)} items", flush=True)
            items.extend(next_page)
        else:
            break

    return items

client = authenticate_zia()
all_url_categories = client_get_all(client.zia.url_categories.list_categories, page_size = 100)

Expected behavior
We only retrieve the specified pagesize and response.next retrieves the next page, not the same page again.

Is it a regression?
Category retrieval did work properly on SDK versions before version 1

Debug Logs
Available via ticket upon request

Other Information

  • OS: Windows
  • SDK Version: 1.9.0

Additional context
N/A

Metadata

Metadata

Assignees

Labels

❓ questionFurther information is requested

Type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions