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
- Make a
GET request to /api/v1/collisions or /api/v1/agents/runs with size=10 and a total of 50 records[cite: 1].
- Observe that the API returns
pages=59 instead of the correct value of 5[cite: 1].
Steps to reproduce
Steps to Reproduce
- Make a
GET request to /api/v1/collisions or /api/v1/agents/runs with size=10 and a total of 50 records[cite: 1].
- Observe that the API metadata returns
pages=59 instead of the correct value of 5[cite: 1].
Expected behavior
Expected Behavior
The API calculates the pages field 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
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