jamiepine/voicebox · error · ValueError
Profile not found: {profile_id}
Error message
Profile not found: {profile_id} What it means
Raised by create_voice_prompt_from_profile() when no DBVoiceProfile row matches the supplied profile_id. The function queries DBVoiceProfile by id and immediately aborts if the row is absent, because every subsequent branch (preset/designed/cloned) dereferences profile fields. It is a caller-contract failure: the caller referenced a profile that does not exist in the current database session.
Source
Thrown at backend/services/profiles.py:542
For cloned profiles: combines all audio samples into a voice prompt.
For preset profiles: returns the engine-specific preset voice reference.
For designed profiles: returns the text design prompt (future).
Args:
profile_id: Profile ID
db: Database session
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,
}
View on GitHub (pinned to 51f49dea19)
Solutions
- Verify the profile exists before calling: profile = db.query(DBVoiceProfile).filter_by(id=profile_id).first(); if not profile: return 404.
- Check the profile_id type matches the DBVoiceProfile.id column type (string UUID vs integer) and that you are passing the correct value.
- If the id originates from the client, validate it against the database in the API route before reaching the service layer.
- Confirm migrations/seeds have run so that referenced profiles (including preset profiles) exist.
Example fix
// before
prompt = await create_voice_prompt_from_profile(profile_id, db, engine=engine)
// after
profile = db.query(DBVoiceProfile).filter_by(id=profile_id).first()
if not profile:
raise HTTPException(404, f"Profile not found: {profile_id}")
prompt = await create_voice_prompt_from_profile(profile_id, db, engine=engine) Defensive patterns
Strategy: validation
Validate before calling
from backend.models import DBVoiceProfile
def profile_exists(db, profile_id) -> bool:
return db.query(DBVoiceProfile).filter_by(id=profile_id).first() is not None
# before calling create_voice_prompt_from_profile
if not profile_exists(db, profile_id):
raise HTTPException(404, f"Profile not found: {profile_id}") Try / catch
try:
prompt = await create_voice_prompt_from_profile(profile_id, db, engine=engine)
except ValueError as e:
if "Profile not found" in str(e):
raise HTTPException(404, str(e))
raise Prevention
- Always validate profile_id against the DB at the API boundary before reaching service code.
- Return 404 immediately for unknown profiles; do not pass stale ids from client caches.
- Ensure migrations/seeds have run so referenced profiles exist in every environment.
When it happens
Trigger: Calling create_voice_prompt_from_profile(profile_id=<id>, db=..., engine=...) where <id> is not present in the voice_profiles table; passing a string vs int id mismatch; passing a profile_id from a different tenant/database; calling after the profile was deleted in another session.
Common situations: Stale profile_id cached client-side after deletion; race where a profile is removed between a list call and a generate call; test fixtures that reference hardcoded ids not seeded; typo or copy/paste of an id string; using a database that was not migrated to contain preset/designed seed profiles.
Related errors
- Profile {profile_id} not found
- Profile {profile_id} not found
- No samples found for profile {profile_id}
- {exception message from set_channel_voices (ValueError)}
- Profile not found
AI-assisted analysis of jamiepine/voicebox@51f49dea19 (2026-08-12).
Data as JSON: /api/errors/74b38836e8e950b5.
Report an issue: GitHub.