jamiepine/voicebox · warning · ValueError
A preset named '{data.name}' already exists
Error message
A preset named '{data.name}' already exists What it means
create_preset() queries DBEffectPreset by name before insert; if a row already has that name it raises ValueError. Names are globally unique across built-in and user presets (the DB also enforces uniqueness, see error 225). This is the optimistic pre-check that catches the common case.
Source
Thrown at backend/services/effects.py:66
"""Get a preset by name."""
p = db.query(DBEffectPreset).filter_by(name=name).first()
if not p:
return None
return _preset_response(p)
def create_preset(data: EffectPresetCreate, db: Session) -> EffectPresetResponse:
"""Create a new user effect preset."""
chain_dicts = [e.model_dump() for e in data.effects_chain]
error = validate_effects_chain(chain_dicts)
if error:
raise ValueError(error)
# Check for duplicate name before insert
existing = db.query(DBEffectPreset).filter_by(name=data.name).first()
if existing:
raise ValueError(f"A preset named '{data.name}' already exists")
preset = DBEffectPreset(
id=str(uuid.uuid4()),
name=data.name,
description=data.description,
effects_chain=json.dumps(chain_dicts),
is_builtin=False,
)
db.add(preset)
try:
db.commit()
except IntegrityError:
db.rollback()
raise ValueError(f"A preset named '{data.name}' already exists")
db.refresh(preset)
return _preset_response(preset)
View on GitHub (pinned to 51f49dea19)
Solutions
- Choose a different name.
- Call get_preset_by_name(name) first to detect the collision earlier and guide the user.
- Delete or rename the existing preset before recreating.
Example fix
# before
create_preset(EffectPresetCreate(name='Radio', ...), db)
# after — pick a unique name
base, n, name = 'Radio', 1, 'Radio'
while get_preset_by_name(name, db):
n += 1
name = f'{base} ({n})'
create_preset(EffectPresetCreate(name=name, ...), db) Defensive patterns
Strategy: validation
Validate before calling
from backend.services.effects import get_preset_by_name
def name_available(name, db) -> bool:
return get_preset_by_name(name, db) is None Try / catch
try:
create_preset(data, db)
except ValueError as e:
if "already exists" in str(e):
# suggest an alternate name (e.g. append ' (1)')
...
raise Prevention
- Reserve built-in preset names (Robotic, Radio, Echo Chamber, Deep Voice) on the client.
- Pre-check with get_preset_by_name before enabling the submit button.
When it happens
Trigger: POST create-preset with a name colliding with an existing preset — either a built-in ('Robotic', 'Radio', 'Echo Chamber', 'Deep Voice' from BUILTIN_PRESETS) or another user preset.
Common situations: User reusing a built-in name; restoring a preset export over an existing name; double-submit in the UI.
Related errors
- Unknown effect type '{effect_type}' at index {i}. Available:
- Effect '{effect_type}' at index {i}: param '{param_name}' mu
- Generation is not completed
- {validation error from validate_effects_chain}
- {exception message from create_preset (ValueError)}
AI-assisted analysis of jamiepine/voicebox@51f49dea19 (2026-08-12).
Data as JSON: /api/errors/a312c056a0c55435.
Report an issue: GitHub.