jamiepine/voicebox · warning · ValueError
Profile {profile_id} has no samples
Error message
Profile {profile_id} has no samples What it means
After finding the profile, export_profile_to_zip() queries DBProfileSample by profile_id; an empty result raises ValueError. A profile with zero samples has no audio to archive, so the export is rejected up front rather than producing an empty zip.
Source
Thrown at backend/services/export_import.py:67
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.suffix
zip_file.write(avatar_path, f"avatar{avatar_ext}")
# Create manifest.json
manifest = {
"version": "1.0",View on GitHub (pinned to 51f49dea19)
Solutions
- Record or upload at least one sample before exporting.
- Disable Export in the UI until the profile has at least one sample.
- Surface this ValueError as 400/409 with a clear 'add samples first' message.
Example fix
# before — export immediately after create
data = export_profile_to_zip(new_profile_id, db)
# after — only export once samples exist
if db.query(DBProfileSample).filter_by(profile_id=pid).count() == 0:
return None
data = export_profile_to_zip(pid, db) Defensive patterns
Strategy: validation
Validate before calling
from backend.database import ProfileSample as DBProfileSample
def has_samples(profile_id, db) -> bool:
return db.query(DBProfileSample).filter_by(profile_id=profile_id).count() > 0 Try / catch
try:
data = export_profile_to_zip(pid, db)
except ValueError as e:
if "has no samples" in str(e):
# prompt user to add at least one sample
...
raise Prevention
- Show sample count in the profile list; disable Export when it's 0.
- Validate before issuing the export request rather than after.
When it happens
Trigger: Exporting a freshly-created profile before any samples are recorded/uploaded; a profile whose samples were all deleted but whose row remains.
Common situations: User clicks Export too early; empty profile object left in the list; samples removed via a separate flow.
Related errors
AI-assisted analysis of jamiepine/voicebox@51f49dea19 (2026-08-12).
Data as JSON: /api/errors/f8f7d157601bdeba.
Report an issue: GitHub.