jamiepine/voicebox · error · ValueError
Error importing generation: {str(e)}
Error message
Error importing generation: {str(e)} What it means
Catch-all for the generation import path: any non-BadZipFile, non-JSONDecodeError, non-ValueError exception inside the with-zipfile block is normalized into ValueError(f"Error importing generation: {str(e)}") (export_import.py:458-461). ValueError subclasses (including the manifest/audio/profile precondition checks above) are re-raised verbatim by the isinstance(e, ValueError) guard.
Source
Thrown at backend/services/export_import.py:461
"id": db_generation.id,
"profile_id": profile_id,
"profile_name": profile_name,
"text": db_generation.text,
"message": f"Generation imported successfully (assigned to profile: {profile_name})"
}
finally:
# Clean up temp file
Path(tmp_path).unlink(missing_ok=True)
except zipfile.BadZipFile:
raise ValueError("Invalid ZIP file")
except json.JSONDecodeError as e:
raise ValueError(f"Invalid JSON in archive: {e}")
except Exception as e:
if isinstance(e, ValueError):
raise
raise ValueError(f"Error importing generation: {str(e)}")
View on GitHub (pinned to 51f49dea19)
Solutions
- Inspect the {str(e)} tail to identify the underlying exception type and message.
- If OSError/PermissionError: check write permissions and free space on config.get_generations_dir().
- If sqlalchemy IntegrityError: check for a duplicate generation id and ensure the importer uses str(uuid4()) (it does in stock code).
- If config.to_storage_path fails, verify the storage root is configured and absolute.
Example fix
# before: generations dir not writable # after: point config at a writable dir export GENERATIONS_DIR=/var/lib/voicebox/generations
Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
try:
result = await import_generation_from_bytes(file_bytes, db)
except ValueError as e:
msg = str(e)
if msg.startswith('Error importing generation:'):
logger.exception('generation import failed: %s', msg)
raise HTTPException(500, 'Generation import failed; see server logs.')
raise HTTPException(400, msg) Prevention
- Ensure config.get_generations_dir() exists and is writable before enabling imports.
- Monitor free disk space; shutil.copy fails fast on ENOSPC.
- Wrap the import in a transaction so a failed DB insert rolls back cleanly.
- Log the underlying exception chain, not just the wrapped ValueError.
When it happens
Trigger: shutil.copy fails (disk full / permission denied writing to generations_dir); DBGeneration insert raises sqlalchemy IntegrityError (duplicate id from a UUID collision or re-import without new id); config.get_generations_dir() returns an unwritable path; config.to_storage_path raises.
Common situations: Storage volume full; UUID collision from importing the same generation twice with deterministic IDs (the importer generates fresh UUIDs so this is unlikely unless the code was patched); permission issues on the generations directory.
Related errors
- Error importing profile: {str(e)}
- No voice profiles found. Please create a profile before impo
- Generation {generation_id} not found
- Invalid manifest.json: missing generation data
- Invalid manifest.json: missing generation.{field}
AI-assisted analysis of jamiepine/voicebox@51f49dea19 (2026-08-12).
Data as JSON: /api/errors/a395390690edf35f.
Report an issue: GitHub.