Skip to content

[Bug]: Sync Audio Pipeline KeyError on Missing Contact Name or ID #19008

Closed

Description

@kduailabs

Describe the bug

In backend/utils/sync/pipeline.py:

  1. build_person_embeddings_cache:
for person in people or []:
    emb = usable_person_voiceprint(person)
    if emb:
        cache[person['id']] = {
            'embedding': np.array(emb, dtype=np.float32).reshape(1, -1),
            'name': person['name'],
        }

If a Firestore person document has an embedding or voiceprint but has no 'name' key (or 'id' is missing), accessing person['name'] raises KeyError: 'name'.

  1. identify_speakers_for_segments:
person = users_db.get_person_by_name(uid, detected_name)
if person:
    segment_person_assignment_map[seg.id] = person['id']
    if speaker_id > 0:
        speaker_to_person_map[speaker_id] = (person['id'], person['name'])

If person found by name is missing 'name' or 'id', indexing person['name'] or person['id'] raises KeyError.

Expected Behavior

  • build_person_embeddings_cache should ensure person.get('id') is truthy and default name to person.get('name') or 'Unknown'.
  • identify_speakers_for_segments should guard person and person.get('id') and fallback name to person.get('name') or detected_name.

Reproduction

Run build_person_embeddings_cache with a person document {'id': 'p1', 'speech_samples': [{'embedding': [0.1]*192}]} without a 'name' key:
KeyError: 'name' is raised.

Proposed Fix

  1. In build_person_embeddings_cache, guard if emb and person.get('id'): and set 'name': person.get('name') or 'Unknown'.
  2. In identify_speakers_for_segments, check if person and person.get('id'): and set speaker_to_person_map[speaker_id] = (person['id'], person.get('name') or detected_name).
  3. Add unit test coverage in backend/tests/unit/test_sync_pipeline_contact_guards.py.

Product invariants affected

none

Failure-Class: none

Activity

  1. kduailabs commented on Sep 25, 2026

    @kduailabs
    ContributorAuthor

    Bounty Program Claim

  2. added 2 commits that reference this issue on Sep 26, 2026
    976dc95
    af99d08
  3. added a commit that references this issue on Oct 2, 2026
    fd7b727
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions