Skip to content

fix(api): return 400 for non-positive per_page instead of 500#9429

Open
Syed-Ali-Abbas-Zaidi wants to merge 1 commit into
makeplane:previewfrom
Syed-Ali-Abbas-Zaidi:fix/9426-per-page-validation
Open

fix(api): return 400 for non-positive per_page instead of 500#9429
Syed-Ali-Abbas-Zaidi wants to merge 1 commit into
makeplane:previewfrom
Syed-Ali-Abbas-Zaidi:fix/9426-per-page-validation

Conversation

@Syed-Ali-Abbas-Zaidi

@Syed-Ali-Abbas-Zaidi Syed-Ali-Abbas-Zaidi commented Jul 16, 2026

Copy link
Copy Markdown

The work items list endpoint (and every other paginated v1 endpoint) validated per_page for non-numeric and oversized values but not for zero or negative ones. Those fell through get_per_page and crashed downstream in the paginator, surfacing as an unhelpful HTTP 500 that clients retry.

Reject per_page <= 0 in BasePaginator.get_per_page with a 400 ParseError ("Invalid per_page value. Must be a positive integer."), matching the existing non-numeric and too-large validation cases.

Add contract tests covering per_page=0, negative, non-numeric, oversized, and valid values on the work items list endpoint.

Closes #9426

Description

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

Test Scenarios

References

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation for issue list pagination.
    • Invalid, non-numeric, non-positive, or excessively large per_page values now return a clear HTTP 400 error.
    • Valid pagination values continue to work as expected.

@CLAassistant

CLAassistant commented Jul 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ef9d408c-69f1-4338-aa01-1c1e02821398

📥 Commits

Reviewing files that changed from the base of the PR and between af1be50 and 0f27fe2.

📒 Files selected for processing (2)
  • apps/api/plane/tests/contract/api/test_issues.py
  • apps/api/plane/utils/paginator.py

📝 Walkthrough

Walkthrough

The paginator now rejects non-positive per_page values with a validation error. Contract tests cover zero, negative, non-numeric, oversized, and valid per_page values for the issues list endpoint.

Changes

per_page validation

Layer / File(s) Summary
Paginator validation and issue-list coverage
apps/api/plane/utils/paginator.py, apps/api/plane/tests/contract/api/test_issues.py
BasePaginator rejects non-positive values with a ParseError, and contract tests verify 400 responses for invalid values and 200 for a valid value.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: dheeru0198

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main fix: returning 400 for non-positive per_page values instead of 500.
Description check ✅ Passed The description covers the change, type of change, issue reference, and test coverage, matching the template well.
Linked Issues check ✅ Passed The code updates BasePaginator validation and adds tests for zero, negative, non-numeric, oversized, and valid per_page cases, matching #9426.
Out of Scope Changes check ✅ Passed The changes are limited to paginator validation and related contract tests, with no clear out-of-scope additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

[bug]: Work items API returns HTTP 500 for per_page=0 or negative values instead of a validation error

2 participants