Skip to content

Reject bool values in pagination limits - #133

Open
mohityadav8 wants to merge 1 commit into
prooflinedev:mainfrom
mohityadav8:fix/page-limits-bool-guard
Open

mohityadav8 wants to merge 1 commit into
prooflinedev:mainfrom
mohityadav8:fix/page-limits-bool-guard

Conversation

@mohityadav8

Copy link
Copy Markdown

_page_limits accepted True/False as page_size, max_pages, or max_items since bool is an int subclass in Python, silently treating them as 1/0 instead of raising. _export_page_limit already guards against this; bring _page_limits in line with it. Verified: _page_limits(True, 10, 100) raised nothing before the fix, raises ValueError after. Same 3 pre-existing test failures (openapi-python-client metadata, Windows socket timing flakes) reproduce identically on main, confirming this change introduces no regressions.

_page_limits accepted True/False as page_size, max_pages, or max_items since bool is an int subclass in Python, silently treating them as 1/0 instead of raising. _export_page_limit already guards against this; bring _page_limits in line with it. Verified: _page_limits(True, 10, 100) raised nothing before the fix, raises ValueError after. Same 3 pre-existing test failures (openapi-python-client metadata, Windows socket timing flakes) reproduce identically on main, confirming this change introduces no regressions.

@aman-ali07 aman-ali07 left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this — _export_page_limit is a good precedent to follow, and the bool fix reads clearly.

I checked the behaviour by extracting _page_limits from main and from your head: on main, _page_limits(True, 10, 100) returns without error; on your head it raises ValueError: Pagination requires page_size 1..100, .... So the change does what it says.

One optional extra, if you have time: there does not seem to be a test that calls _page_limits yet (the only references I found were the two call sites at client.py:519,914). A tiny parametrized test would keep the bool case from coming back. I sketched one in this comment — please use any part of it that is useful, or ignore it if you would rather handle coverage elsewhere.

I verified by extracting the function rather than by running pytest, since this checkout has no Python deps installed. No repo of yours was touched. Nice small fix, and thanks for noting the pre-existing failures — that was helpful context.

Comment thread proofline/client.py

def _page_limits(page_size: int, max_pages: int, max_items: int) -> None:
if not 1 <= page_size <= 100 or not 1 <= max_pages <= 1_000 or not 1 <= max_items <= 100_000:
if (

@aman-ali07 aman-ali07 Nov 28, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic looks good to me. If you would like a companion test, a small parametrized one in tests/ would keep the bool case from coming back — there is no coverage of _page_limits in the suite today. Totally optional, and happy with whatever you prefer.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants