-
Notifications
You must be signed in to change notification settings - Fork 41
[Bug]: Incorrect Pagination Calculation in API Endpoints #191
Copy link
Copy link
Open
Labels
apiRelated to APIs or backend endpoints.Related to APIs or backend endpoints.assignedIndicates that the issue has been assigned to a contributor who is actively working on it.Indicates that the issue has been assigned to a contributor who is actively working on it.backendBackend developmentBackend developmentbugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or requesttype:backendChanges backend services or server-side logic.Changes backend services or server-side logic.type:bugFixes an existing bug or unexpected behavior.Fixes an existing bug or unexpected behavior.type:featureIntroduces a new feature or enhancement.Introduces a new feature or enhancement.
Description
Activity
Metadata
Metadata
Assignees
Labels
apiRelated to APIs or backend endpoints.Related to APIs or backend endpoints.assignedIndicates that the issue has been assigned to a contributor who is actively working on it.Indicates that the issue has been assigned to a contributor who is actively working on it.backendBackend developmentBackend developmentbugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or requesttype:backendChanges backend services or server-side logic.Changes backend services or server-side logic.type:bugFixes an existing bug or unexpected behavior.Fixes an existing bug or unexpected behavior.type:featureIntroduces a new feature or enhancement.Introduces a new feature or enhancement.
Bug description
[Bug]: Incorrect Pagination Calculation in API Endpoints
Description
As an ECSoC'26 contributor reviewing the backend endpoints (referencing the file kepler.pdf verbatim), I identified a logical bug in the pagination calculations across several FastAPI routes[cite: 1].
Issues Identified
Across multiple endpoints (such as
/collisions,/agents, and/weather), the calculation for the total number of pages is mathematically incomplete[cite: 1].The code currently evaluates:
pages = (total + size - 1)[cite: 1]This calculation is missing the integer division operation by the page
size, meaning the API returns wildly inaccurate page counts[cite: 1].Steps to Reproduce
GETrequest to/api/v1/collisionsor/api/v1/agents/runswithsize=10and atotalof 50 records[cite: 1].pages=59instead of the correct value of5[cite: 1].Steps to reproduce
Steps to Reproduce
GETrequest to/api/v1/collisionsor/api/v1/agents/runswithsize=10and atotalof 50 records[cite: 1].pages=59instead of the correct value of5[cite: 1].Expected behavior
Expected Behavior
The API calculates the
pagesfield correctly using integer division, yielding an accurate total page count based on the number of records and the requested page size[cite: 1].Actual behavior
Actual Behavior
The code currently evaluates the total pages using simple addition and subtraction:
pages = (total + size - 1)[cite: 1]. Because it lacks the final division operation by the page size, the API returns wildly inaccurate and inflated page counts[cite: 1].Screenshots or recordings
No response
Platform
API
Environment
No response
Error messages or logs
Difficulty
None
Priority
None
Additional information
No response