Skip to content

Test: Pagination._check validator crashes with ZeroDivisionError on empty results #32

@rajjaa-hr

Description

@rajjaa-hr

Summary

The Pagination._check root validator in tests/utils/schemas.py crashes with ZeroDivisionError whenever the API returns an empty paginated result set (maxPage=0, total=0, count=0).

The offending line:

per_page = total / max_page

max_page is 0 in this case, so the division fails before any of the assertions run.

Reproduction

Run test_job_searching_basic against a board that has no jobs (or any searching test where the result set is empty):

FAILED tests/test_job.py::test_job_searching_basic - ZeroDivisionError: division by zero

cls = <class 'tests.utils.schemas.Pagination'>
values = {'count': 0, 'facets': None, 'maxPage': 0, 'page': 1, ...}

>       per_page = total / max_page
E       ZeroDivisionError: division by zero

Scope

Pre-existing bug in the test-only validator (not in the production hrflow package). Not introduced by the pydantic v1→v2 migration — it would fail identically on v1.

Suggested fix

Short-circuit the pagination consistency checks when max_page == 0 (nothing to validate on an empty result set), or guard against the divide-by-zero directly.

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