West Midlands | 26 March SDC | Iswat Bello | Sprint 1 | Purple Forest/bug report/Extra long blooms#210
Conversation
nedssoft
left a comment
There was a problem hiding this comment.
Excellent thinking, Iswat — spotting that the 280-char limit was only enforced on the frontend and could be bypassed by a script or direct API call is exactly the "never trust the client" instinct that makes a good backend dev. 👏 Pulling the limit into a named MAX_BLOOM_LENGTH and returning a clean 400 is spot on, with thorough DB verification.
One small thing to mull (not blocking): your message says a bloom must be "less than 280 characters", but your check > MAX_BLOOM_LENGTH actually lets exactly 280 through. Is 280 meant to be allowed or rejected — and does the wording match what the code does?
Updated the validation error message from "less than" to "not exceed". This ensures the text accurately reflects the backend logic, which allows blooms of exactly 280 characters while rejecting 281+.
Thank you so much @nedssoft, for the feedback. |
Learners, PR Template
Self checklist
Changelist
This PR fixes a bug whereby the application allowed blooms (posts) longer than 280 characters to be saved to the database. While the frontend had validation, the backend lacked a "security guard" to prevent direct API requests or scripts from bypassing the limit.
The Problem: The application was only validating bloom length on the frontend. This allowed scripts (like
populate.py) or direct API requests to save blooms longer than 280 characters, breaking the business rules.The Fix:
MAX_BLOOM_LENGTHconstant (280) to the backend.send_bloomfunction inendpoints.pyto check the length of the incoming content.400 Bad Requestif the bloom exceeds the limit.Verification:
populate.py.