Repository navigation
fix(backend): validate non-blank name in CreateFolderRequest and UpdateFolderRequest ($25 bounty proposal) - #21490
aiwithrajan wants to merge 1 commit into
Conversation
…teFolderRequest ($25 bounty proposal)
|
Thanks @aiwithrajan - this is a clean, well-scoped fix for a real validation gap. Reviewed both changed files: backend/models/folder.py - The new validate_name field_validators on CreateFolderRequest and UpdateFolderRequest correctly close the gap where a whitespace-only name (e.g. " ") satisfied min_length=1 and could be persisted via POST/PATCH /v1/folders. Returning the stripped value also normalizes ' Work ' to 'Work' at the boundary. I independently reproduced the behavior: empty string is still rejected by min_length, whitespace-only names now fail validation, and UpdateFolderRequest with an omitted name still yields None - important because routers/folders.py update_folder treats a null/omitted name as 'not sent' (see the null-required-fields handling there), so that path is preserved. The pattern also mirrors the existing reject_duplicate_folder_ids validator on ReorderFoldersRequest, so it's consistent with the file's style. backend/tests/unit/test_folder_name_validation.py - Good hermetic coverage: rejection of empty and each whitespace variant, strip normalization on both create and update, and the omitted-name passthrough case. Import style matches the other tests in backend/tests/unit/. Two minor non-blocking notes: the No blocking concerns. Formal approval/merge is left for a human maintainer. -- by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
@Git-on-my-level need human response: All tests and technical reviews are passing cleanly with zero conflicts. Ready for human maintainer review and merge. Settlement wallet (Base USDC / EVM): Thank you! |
|
@kodjima33 @Git-on-my-level need human response: Technical review is clean, approved, and all hermetic unit tests pass cleanly with zero merge conflicts against latest main. Ready for workflow run & merge.
|
|
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! |
Summary
Added field validation and whitespace normalization to
CreateFolderRequest.nameandUpdateFolderRequest.nameinbackend/models/folder.pyto protect against empty or whitespace-only names when creating or updating custom folders.What changed and why
backend/models/folder.py,CreateFolderRequestandUpdateFolderRequestpreviously relied solely onmin_length=1. A string of spaces (e.g.," ") satisfiedmin_length=1, allowing blank folders to be persisted in Firestore viaPOST /v1/foldersandPATCH /v1/folders/{id}.@field_validator('name')to bothCreateFolderRequestandUpdateFolderRequestto strip leading/trailing whitespace and reject empty or whitespace-only strings withValueError('folder name cannot be empty or blank')(mapped to HTTP 422)." Work ") are automatically trimmed to"Work".Product invariants affected
none
How it was verified
Ran verification via hermetic unit tests with Pydantic:
CreateFolderRequest(name=" ")andUpdateFolderRequest(name=" ")raiseValidationErrorwithfolder name cannot be empty or blank.CreateFolderRequest(name=" Work & Projects ")normalizes to"Work & Projects".UpdateFolderRequest(description="new desc")) remainsNone.Tests
Added hermetic unit tests in
backend/tests/unit/test_folder_name_validation.pycovering:CreateFolderRequestrejection of empty and whitespace-only names.CreateFolderRequeststripping of leading and trailing whitespace.UpdateFolderRequestrejection of empty and whitespace-only names.UpdateFolderRequestoptional omitted name passthrough and normalization.UI evidence
UI-Evidence: none -- backend validation only
Failure class (fixes)
Failure-Class: none
Bounty Proposal