jamiepine/voicebox · error · ValueError

Preset profile {profile_id} is missing preset engine metadat

Error message

Preset profile {profile_id} is missing preset engine metadata

What it means

Raised inside the preset branch of create_voice_prompt_from_profile() when a profile whose voice_type == 'preset' lacks either preset_engine or preset_voice_id. A preset profile is meant to reference a built-in engine voice, so both metadata fields are mandatory. This is a data-integrity error: the profile row is malformed and cannot be used to synthesize speech.

Source

Thrown at backend/services/profiles.py:550

        use_cache: Whether to use cached prompts
        engine: TTS engine to create prompt for

    Returns:
        Voice prompt dictionary
    """
    from ..backends import get_tts_backend_for_engine

    profile = db.query(DBVoiceProfile).filter_by(id=profile_id).first()
    if not profile:
        raise ValueError(f"Profile not found: {profile_id}")

    voice_type = getattr(profile, "voice_type", None) or "cloned"
    validate_profile_engine(profile, engine)

    # ── Preset profiles: return engine-specific voice reference ──
    if voice_type == "preset":
        if not profile.preset_engine or not profile.preset_voice_id:
            raise ValueError(f"Preset profile {profile_id} is missing preset engine metadata")
        if profile.preset_engine != engine:
            raise ValueError(
                f"Preset profile {profile_id} only supports engine '{profile.preset_engine}', not '{engine}'"
            )
        return {
            "voice_type": "preset",
            "preset_engine": profile.preset_engine,
            "preset_voice_id": profile.preset_voice_id,
        }

    # ── Designed profiles: return text description (future) ──
    if voice_type == "designed":
        if not profile.design_prompt or not profile.design_prompt.strip():
            raise ValueError(f"Designed profile {profile_id} is missing design_prompt")
        return {
            "voice_type": "designed",
            "design_prompt": profile.design_prompt,
        }

View on GitHub (pinned to 51f49dea19)

Solutions

  1. Backfill the missing fields on the profile row: UPDATE voice_profiles SET preset_engine=..., preset_voice_id=... WHERE id=....
  2. Recreate the preset profile through the normal create_profile flow so all required fields are set.
  3. If the row is genuinely invalid, delete it and let it be re-seeded.
  4. Add a NOT NULL constraint (and an app-layer validator) on preset_engine/preset_voice_id when voice_type='preset' to prevent recurrence.

Example fix

// before: profile row has voice_type='preset', preset_engine=NULL
// after: ensure both metadata fields are populated
profile.preset_engine = 'qwen'
profile.preset_voice_id = 'cherry'
db.commit()
Defensive patterns

Strategy: validation

Validate before calling

from backend.models import DBVoiceProfile

def is_preset_profile_complete(profile) -> bool:
    if (profile.voice_type or 'cloned') != 'preset':
        return True
    return bool(profile.preset_engine and profile.preset_voice_id)

profile = db.query(DBVoiceProfile).filter_by(id=profile_id).first()
if not is_preset_profile_complete(profile):
    raise HTTPException(409, 'Preset profile is missing engine metadata')

Try / catch

try:
    prompt = await create_voice_prompt_from_profile(profile_id, db, engine=engine)
except ValueError as e:
    if 'missing preset engine metadata' in str(e):
        # flag for data backfill / re-seed
        log_data_integrity(profile_id)
        raise HTTPException(409, str(e))
    raise

Prevention

When it happens

Trigger: A preset profile row was inserted with NULL preset_engine or preset_voice_id; an ORM update cleared one field; a manual DB edit populated voice_type='preset' without the supporting metadata; a migration populated preset profiles incompletely.

Common situations: Seeding scripts that set voice_type but skip metadata; partial writes during profile creation; schema changes that added preset_engine/preset_voice_id columns after existing rows were created; manual SQL inserts used to bootstrap test data.

Related errors


AI-assisted analysis of jamiepine/voicebox@51f49dea19 (2026-08-12). Data as JSON: /api/errors/ba9580a93cc7598d. Report an issue: GitHub.