jamiepine/voicebox · error · ValueError
Generation {generation_id} not found
Error message
Generation {generation_id} not found What it means
Raised by export_generation_to_zip when db.query(DBGeneration).filter_by(id=generation_id).first() returns None (export_import.py:261-262). The generation row does not exist in the database — either it was deleted, the ID is wrong, or it belongs to a different database/tenant.
Source
Thrown at backend/services/export_import.py:262
def export_generation_to_zip(generation_id: str, db: Session) -> bytes:
"""
Export a generation to a ZIP archive.
Args:
generation_id: Generation ID to export
db: Database session
Returns:
ZIP file contents as bytes
Raises:
ValueError: If generation not found
"""
# Get generation
generation = db.query(DBGeneration).filter_by(id=generation_id).first()
if not generation:
raise ValueError(f"Generation {generation_id} not found")
# Get profile info
profile = db.query(DBVoiceProfile).filter_by(id=generation.profile_id).first()
if not profile:
raise ValueError(f"Profile {generation.profile_id} not found")
# Get all versions for this generation
versions = (
db.query(DBGenerationVersion)
.filter_by(generation_id=generation_id)
.order_by(DBGenerationVersion.created_at)
.all()
)
# Create ZIP in memory
zip_buffer = io.BytesIO()
with zipfile.ZipFile(zip_buffer, 'w', zipfile.ZIP_DEFLATED) as zip_file:View on GitHub (pinned to 51f49dea19)
Solutions
- Confirm the ID exists: SELECT id, created_at FROM generations WHERE id = '<id>';.
- If the row is missing, re-run the generation — the audio file alone cannot reconstruct the DB record.
- Check that the request is hitting the same backend instance/environment where the generation was created.
- Validate the ID format (UUID) before issuing the request to fail fast client-side.
Example fix
# before: passing an unvalidated id straight through
gen = export_generation_to_zip(possibly_bad_id, db)
# after: existence check, 404-friendly error
gen = db.query(DBGeneration).filter_by(id=generation_id).first()
if not gen:
raise HTTPException(status_code=404, detail="Generation not found") Defensive patterns
Strategy: validation
Validate before calling
def generation_exists(db, generation_id: str) -> bool:
return db.query(DBGeneration).filter_by(id=generation_id).first() is not None
# in the route handler:
if not generation_exists(db, generation_id):
raise HTTPException(404, f'Generation {generation_id} not found')
zip_bytes = export_generation_to_zip(generation_id, db) Type guard
null
Try / catch
try:
zip_bytes = export_generation_to_zip(generation_id, db)
except ValueError as e:
if 'not found' in str(e):
raise HTTPException(404, str(e))
raise HTTPException(400, str(e)) Prevention
- Validate UUID format and existence before calling the exporter.
- Hide UI affordances for generations that have been deleted.
- Confirm the environment (dev/prod) before reusing a generation ID.
When it happens
Trigger: API call GET /generations/{id}/export with an ID that is not in the generations table; the row was hard-deleted; the caller is hitting a different environment (dev vs prod) than where the generation was created; the ID has a typo or was URL-mangled.
Common situations: Stale bookmarked URL after the generation was deleted; copying an ID from a chatbot log that was already garbage-collected; multi-tenant system pointing at the wrong tenant's DB session.
Related errors
- Generation has no audio file
- Audio file not found
- Profile {profile_id} not found
- Profile {generation.profile_id} not found
- No voice profiles found. Please create a profile before impo
AI-assisted analysis of jamiepine/voicebox@51f49dea19 (2026-08-12).
Data as JSON: /api/errors/482d7f690cdb728b.
Report an issue: GitHub.