Repository navigation
fix(backend): validate non-blank person name in CreatePerson and update_person_name ($25 bounty proposal) - #21506
aiwithrajan wants to merge 1 commit into
Conversation
|
Thanks @aiwithrajan - verified this end to end and it's a real bug fix. Verified the premise against current main: in
Ran the new suites plus the full No blocking concerns from me; leaving formal approval and merge to a human maintainer. This comment is AI-generated feedback on behalf of the maintainers. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
…te_person_name ($25 bounty proposal) Failure-Class: none
d6de21f to
6142487
Compare
|
Thanks @aiwithrajan — verified this on head 6142487 in an isolated sandbox; all observations below are from actually running the code.
One non-blocking thought: the inline checks in update_person_name duplicate the CreatePerson validator logic; if more person-name endpoints appear, extracting a shared helper would keep the bounds in one place. Not needed at this size. This fixes a real correctness bug with clean, focused tests — nice first contribution. Leaving the final approve/merge to the maintainers. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Thanks @Git-on-my-level for the thorough sandbox verification and positive feedback! All tests are passing cleanly and the branch is conflict-free against main. Ready for final maintainer merge @undivisible. |
|
Hey @aiwithrajan 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! |
Description
Validates and sanitizes person names in
CreatePersonandupdate_person_name.Currently:
CreatePersoninbackend/models/other.pydefinesname: str = Field(min_length=2, max_length=40)without stripping whitespace, permitting whitespace-only strings like" "to pass validation. It also creates entries with unstripped surrounding whitespace, preventing idempotent duplicate matching inget_person_by_name.update_person_nameinbackend/routers/users.pyreceives a rawvalue: str(with the intended validation previously left commented out:# = Field(min_length=2, max_length=40)). When given a blank or whitespace-only string, the underlying rename transaction returnsFalse, causing the endpoint to mistakenly raise HTTP 404 ("Person not found") instead of HTTP 422 Unprocessable Entity.This PR:
@field_validator('name')toCreatePersonto strip whitespace and enforce that stripped names are between 2 and 40 characters.valueinupdate_person_nameis non-blank with stripped length between 2 and 40 characters, raising HTTP 422 if invalid, and passes the clean name toupdate_person.backend/tests/unit/test_person_name_validation.pyand router tests inbackend/tests/routers/test_users.py.Test Plan