Skip to content

Validate pagination parameters in campaign leads endpoint - #639

Open
chesta02 wants to merge 1 commit into
Kuldeeep18:mainfrom
chesta02:fix/lo-055-pagination-validation
Open

Validate pagination parameters in campaign leads endpoint#639
chesta02 wants to merge 1 commit into
Kuldeeep18:mainfrom
chesta02:fix/lo-055-pagination-validation

Conversation

@chesta02

@chesta02 chesta02 commented Jul 9, 2026

Copy link
Copy Markdown

Summary

This PR fixes Issue #55 by validating pagination query parameters in the campaign leads endpoint.

Changes

  • Added validation for limit and offset query parameters.

  • Returns HTTP 400 when either parameter is not a valid integer.

  • Clamps limit to a maximum of 200.

  • Prevents negative offset values by defaulting them to 0.

Testing

  • Verified valid integer values work correctly.

  • Verified invalid values return HTTP 400.

  • Verified negative offsets are normalized to 0.

  • Verified large limits are capped at 200.

Summary by CodeRabbit

  • Bug Fixes
    • Improved pagination handling for campaign leads by validating page size and position values.
    • Invalid values now return a clear bad request response instead of causing a server error.
    • Page size is now kept within a safe range, and negative positions are no longer accepted.

@coderabbitai

coderabbitai Bot commented Jul 9, 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 Plus

Run ID: ff8fbd9e-df85-46e6-ae1a-ea04a181aff2

📥 Commits

Reviewing files that changed from the base of the PR and between 4a33158 and 00d7be5.

📒 Files selected for processing (1)
  • backend/campaigns/views.py

📝 Walkthrough

Walkthrough

The CampaignViewSet.leads endpoint's pagination parameter parsing was hardened. Query parameters limit and offset are now parsed with error handling, returning 400 for invalid integers, and clamped to safe bounds before use in queryset slicing.

Changes

Pagination Parameter Validation

Layer / File(s) Summary
Validate and clamp pagination parameters
backend/campaigns/views.py
limit/offset parsing now wraps in try/except returning 400 on invalid values, and clamps limit to [1, 200] and offset to non-negative before pagination slicing.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: validating campaign leads pagination parameters.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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.

@Kuldeeep18

Copy link
Copy Markdown
Owner

Hi @chesta02 👋

LeadOrbit Bot here!

Thanks for opening a pull request and contributing to the project. Before your PR is reviewed, please make sure you've:

We noticed that you haven't starred the repository yet. If you enjoy the project and would like to support it, please consider giving it a ⭐. It helps the project grow and motivates the maintainers.

Once you've starred the repository, your PR will continue through the review process.

Thanks for contributing! 🚀

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