omi icon indicating copy to clipboard operation
omi copied to clipboard

[Bounty Proposal] fix(folders): bulk move deduplication, ID bounds & validation ( - USD)

Open ghazy2001 opened this issue 1 month ago • 1 comments

Bounty Proposal: Folder Bulk-Move Deduplication, ID Bounds & Validation (\ - \ USD)

Pull Request: https://github.com/BasedHardware/omi/pull/23033

Problem & Impact

  1. Firestore Single Commit Contention Crash (HTTP 500): In POST /v1/folders/{folder_id}/conversations/bulk-move, BulkMoveConversationsRequest did not validate or deduplicate conversation IDs. Passing duplicate IDs (common on mobile sync retries or multi-select UI) caused bulk_move_conversations_to_folder to call batch.update() multiple times on the same document reference within a single batch, raising google.api_core.exceptions.InvalidArgument: 400 Multiple operations on document in a single commit and crashing the transaction.
  2. Unbounded Input: Unlike ReorderFoldersRequest, BulkMoveConversationsRequest had no min_length or max_length constraints.
  3. Blank / Whitespace Titles: CreateFolderRequest and UpdateFolderRequest permitted whitespace-only names (" "), allowing empty/invisible folder titles in the database.
  4. Unhandled HTTP 500 on Malformed Folder Read: GET /v1/folders/{folder_id} returned raw database records without handling validation errors, raising ResponseValidationError (HTTP 500) if legacy fields were missing.

Key Improvements in PR #23033

  1. Deduplication & Bounds: Bounded conversation_ids with min_length=1, max_length=500 and added field validator to strip whitespace and deduplicate IDs preserving order.
  2. Defensive Database Layer: Added order-preserving deduplication in bulk_move_conversations_to_folder to guarantee Firestore commit safety even against direct calls.
  3. Folder Name Validation: Added whitespace stripping and blank validation to CreateFolderRequest and UpdateFolderRequest (rejecting empty/whitespace names with HTTP 422).
  4. Graceful 404 on Detail: Protected get_folder with ValidationError handler returning HTTP 404 instead of 500 on corrupted stored records.
  5. Hermetic Test Suite: Added 7 comprehensive hermetic unit tests in backend/tests/unit/test_folder_bulk_move_and_validation.py (all passing hermetically in ~3.6s, total diff ~277 lines).

Designated Payout Channel

ghazy2001 avatar Oct 21 '26 11:10 ghazy2001

Thanks for putting this together. We aren't doing bounties at the moment, so we're closing the bounty proposal issues for now — thanks for the fix! 🙏

undivisible avatar Oct 22 '26 11:10 undivisible