jamiepine/voicebox · error · ValueError
Profile {profile_id} not found
Error message
Profile {profile_id} not found What it means
export_profile_to_zip() looks up DBVoiceProfile by id; if no row matches it raises ValueError. The profile must exist before its samples can be archived.
Source
Thrown at backend/services/export_import.py:62
def export_profile_to_zip(profile_id: str, db: Session) -> bytes:
"""
Export a voice profile to a ZIP archive.
Args:
profile_id: Profile ID to export
db: Database session
Returns:
ZIP file contents as bytes
Raises:
ValueError: If profile not found or has no samples
"""
# Get profile
profile = db.query(DBVoiceProfile).filter_by(id=profile_id).first()
if not profile:
raise ValueError(f"Profile {profile_id} not found")
# Get all samples
samples = db.query(DBProfileSample).filter_by(profile_id=profile_id).all()
if not samples:
raise ValueError(f"Profile {profile_id} has no samples")
# Create ZIP in memory
zip_buffer = io.BytesIO()
with zipfile.ZipFile(zip_buffer, 'w', zipfile.ZIP_DEFLATED) as zip_file:
# Check if profile has avatar
has_avatar = False
if profile.avatar_path:
avatar_path = config.resolve_storage_path(profile.avatar_path)
if avatar_path is not None and avatar_path.exists():
has_avatar = True
# Add avatar to ZIP root with original extension
avatar_ext = avatar_path.suffixView on GitHub (pinned to 51f49dea19)
Solutions
- Verify the profile_id exists before offering the Export action.
- Map this ValueError to 404 at the API layer (not 500).
- Refresh the profile list in the UI when the row is missing.
Example fix
# before
data = export_profile_to_zip(unknown_id, db)
# after
if not db.query(DBVoiceProfile).filter_by(id=pid).first():
return None # API returns 404
data = export_profile_to_zip(pid, db) Defensive patterns
Strategy: validation
Validate before calling
from backend.database import VoiceProfile as DBVoiceProfile
def profile_exists(profile_id, db) -> bool:
return db.query(DBVoiceProfile).filter_by(id=profile_id).first() is not None Try / catch
try:
data = export_profile_to_zip(profile_id, db)
except ValueError as e:
if "not found" in str(e):
return ("not_found", None) # API maps to 404
raise Prevention
- Check existence before exposing the Export action.
- Return 404 (not 500) when this ValueError surfaces at the API.
When it happens
Trigger: Calling the profile-export endpoint with a profile_id that was deleted, never existed, or came from a different database (e.g. after a DB reset/migration).
Common situations: Stale bookmarked export link; profile_id typo; post-migration missing rows; client holding a cached id after the profile was deleted elsewhere.
Related errors
- Generation has no audio file
- Profile {profile_id} not found
- Profile {profile_id} has no samples
- Profile not found: {profile_id}
- {exception message from set_channel_voices (ValueError)}
AI-assisted analysis of jamiepine/voicebox@51f49dea19 (2026-08-12).
Data as JSON: /api/errors/b845b8f582763b98.
Report an issue: GitHub.