Summary
The /retrieve endpoint returns the user's entire Messages array in a single response. As a user accumulates messages the payload grows unboundedly, increasing memory use, serialisation time, and client transfer cost.
Background
Any production-grade list endpoint must support pagination. For this tutorial repo, adding ?offset=0&limit=20 query parameters demonstrates a common REST pattern, adds educational value, and prevents accidental DoS from unbounded fetches.
Affected Areas
web/app.py — Retrieve.post() and get_user_messages()
web/tests/test_app.py — new pagination test cases
README.md — endpoint documentation
Recommended Fix
class Retrieve(Resource):
@requires_auth
def post(self):
offset = request.args.get("offset", 0, type=int)
limit = request.args.get("limit", 20, type=int)
limit = min(limit, 100) # hard cap
all_messages = get_user_messages(request.username)
page = all_messages[offset: offset + limit]
return {"status": 200, "obj": page, "total": len(all_messages)}, 200
Acceptance Criteria
Complexity Estimate
M — requires implementation, tests, and documentation updates.
Priority
Low — tutorial scope, but teaches an important REST pattern.
Auto-identified by workspace issue-logger
Category: enhancement / new feature
Complexity: M
Repository: DewaldOosthuizen/python_rest_tutorial
Summary
The
/retrieveendpoint returns the user's entireMessagesarray in a single response. As a user accumulates messages the payload grows unboundedly, increasing memory use, serialisation time, and client transfer cost.Background
Any production-grade list endpoint must support pagination. For this tutorial repo, adding
?offset=0&limit=20query parameters demonstrates a common REST pattern, adds educational value, and prevents accidental DoS from unbounded fetches.Affected Areas
web/app.py—Retrieve.post()andget_user_messages()web/tests/test_app.py— new pagination test casesREADME.md— endpoint documentationRecommended Fix
Acceptance Criteria
/retrieveaccepts optionaloffsetandlimitquery params (defaults: 0, 20)totalcount alongside the paginated slicelimitis capped at 100 server-sideComplexity Estimate
M — requires implementation, tests, and documentation updates.
Priority
Low — tutorial scope, but teaches an important REST pattern.
Auto-identified by workspace issue-logger
Category: enhancement / new feature
Complexity: M
Repository: DewaldOosthuizen/python_rest_tutorial