omi icon indicating copy to clipboard operation
omi copied to clipboard

[Bounty proposal] fix(database): sanitize uid and guard voice preferences against store failures ($50 proposed)

Open Dragonire9 opened this issue 1 month ago • 2 comments

Problem Description

The assistant voice preferences module (backend/database/voice_preferences.py) reads and persists user voice choices from/to the Firestore data plane. However, it currently has several input sanitization, error resilience, and testability shortcomings:

  1. Unsanitized UID Paths: uid values containing whitespace (e.g. from headers or bearer tokens like " uid123 ") create corrupted document paths in Firestore (/users/ uid123 /) rather than updating canonical user profiles.
  2. Crash on Data Plane Outage: get_assistant_voice queries Firestore without an error handling boundary. If the Firestore data plane experiences a transient timeout or network glitch, calls crash with an unhandled exception instead of safely falling back to DEFAULT_ASSISTANT_VOICE.
  3. Missing Validation on Writes: set_assistant_voice does not validate that uid is a non-empty string, allowing empty/blank strings to write to invalid Firestore paths.
  4. Missing Client Availability Guard: If get_data_plane_firestore_client() returns None, set_assistant_voice encounters an unhandled AttributeError instead of a clear RuntimeError.
  5. Zero Unit Test Coverage: backend/database/voice_preferences.py currently has zero dedicated unit tests.

Proposed Solution

  1. Sanitize UID: Strip whitespace from uid across get_assistant_voice and set_assistant_voice, rejecting empty or blank strings with ValueError on write operations.
  2. Safe Fallback on Read: Wrap Firestore reads in a try/except boundary, logging a warning and safely returning DEFAULT_ASSISTANT_VOICE on document absence or read failure.
  3. Guarded Client Resolution: Explicitly guard against missing data plane clients on writes.
  4. Unit Tests: Add comprehensive unit tests in backend/tests/unit/test_voice_preferences.py covering success cases, missing documents, unhandled exceptions, whitespace sanitization, and invalid inputs.

Proposed Bounty: $50 PayPal: https://paypal.me/Dragonire9 ([email protected])

Dragonire9 avatar Oct 16 '26 17:10 Dragonire9

Hi @josancamon19 @kodjima33 — is there still an approved paid opening for the complete repair in #21899, given the existing claim and open PR #21936?

I'd cover canonical UID handling, safe read fallbacks, explicit invalid-write and missing-client errors, and the full regression coverage, preserving voice normalization and the existing injected-client seam. Could you confirm the remaining scope and acceptance/assignment, the approved amount and currency, and a lawful payout option for an individual based in mainland China before I start? If the existing PR fully covers the work, a quick confirmation is enough.

ayqy avatar Oct 17 '26 11:10 ayqy

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