
Overview
This example starts with an intentionally buggy items endpoint. It converts pagination values to integers but accepts zero, negative and oversized ranges, allowing Python slicing to return misleading pages.
My role
I prepared this as a portfolio demonstration with AI assistance across implementation, tests, documentation and visuals. The deliberately buggy version is kept alongside the correction so the change and its evidence can be inspected. The source package and recorded checks are available on request.
Approach
The fix adds FastAPI query constraints: limit must be 1–100 and offset must be zero or more. Invalid requests receive field-specific HTTP 422 responses before reaching the endpoint. Valid requests retain the same pagination behavior.
Verified result
The same regression failed on all four invalid ranges before the fix and passed against the corrected endpoint. Those requests changed from HTTP 200 to HTTP 422. A valid request for two items at offset one still returned Pencil and Ruler.
Four focused tests passed, covering invalid ranges, valid results, defaults, boundaries and non-integer input. Seven saved before-and-after examples matched hand-checked expectations, using an in-process test client.
Scope
The dataset contains five synthetic items. This demonstrates one focused validation fix; database integration, authentication and deployment are outside its scope.
0 likes · 0 views · Oct 24, 2026
A before-and-after demonstration of a pagination bug, using real FastAPI validation and a focused regression test.