{"record":{"id":"2293c861cfe82e3e","repo":"jamiepine/voicebox","slug":"designed-profiles-cannot-set-preset-engine-or-pres","errorCode":null,"errorMessage":"Designed profiles cannot set preset_engine or preset_voice_id","messagePattern":"Designed profiles cannot set preset_engine or preset_voice_id","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/services/profiles.py","lineNumber":173,"sourceCode":"    existing_profile = db.query(DBVoiceProfile).filter_by(name=data.name).first()\n    if existing_profile:\n        raise ValueError(f\"A profile with the name '{data.name}' already exists. Please choose a different name.\")\n\n    # Auto-set default_engine for preset profiles\n    default_engine = data.default_engine\n    voice_type = data.voice_type or \"cloned\"\n    if voice_type == \"preset\" and data.preset_engine and not default_engine:\n        default_engine = data.preset_engine\n\n    validation_error = _validate_profile_fields(\n        voice_type=voice_type,\n        preset_engine=data.preset_engine,\n        preset_voice_id=data.preset_voice_id,\n        design_prompt=data.design_prompt,\n        default_engine=default_engine,\n    )\n    if validation_error:\n        raise ValueError(validation_error)\n\n    db_profile = DBVoiceProfile(\n        id=str(uuid.uuid4()),\n        name=data.name,\n        description=data.description,\n        language=data.language,\n        voice_type=voice_type,\n        preset_engine=data.preset_engine,\n        preset_voice_id=data.preset_voice_id,\n        design_prompt=data.design_prompt,\n        default_engine=default_engine,\n        personality=data.personality,\n        created_at=datetime.utcnow(),\n        updated_at=datetime.utcnow(),\n    )\n\n    db.add(db_profile)\n    db.commit()","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/jamiepine/voicebox/blob/51f49dea198384b4eb6087b72c17057c6eb1c1cd/backend/services/profiles.py#L155-L191","documentation":"Returned by _validate_profile_fields when voice_type=='designed' but preset_engine or preset_voice_id is set. Designed profiles are described purely by design_prompt; preset fields belong to the 'preset' voice_type and are mutually exclusive with 'designed'.","triggerScenarios":"POSTing {voice_type:'designed', design_prompt:'...', preset_engine:'kokoro'} or including preset_voice_id on a designed profile.","commonSituations":"Switching a profile template from 'preset' to 'designed' without clearing the preset fields; client sending the full field set regardless of voice_type.","solutions":["Omit preset_engine and preset_voice_id entirely when voice_type is 'designed'.","Have the client send only the fields valid for the chosen voice_type.","Add a client-side rule that clears preset fields when the user selects 'designed'."],"exampleFix":"// before\n{\"voice_type\":\"designed\",\"design_prompt\":\"calm voice\",\"preset_engine\":\"kokoro\"}\n// after\n{\"voice_type\":\"designed\",\"design_prompt\":\"calm voice\"}","handlingStrategy":"validation","validationCode":"def designed_is_clean(data) -> bool:\n    return not (data.preset_engine or data.preset_voice_id)\n\nif data.voice_type == \"designed\" and not designed_is_clean(data):\n    raise HTTPException(400, \"designed profiles must not include preset_engine/preset_voice_id\")","typeGuard":"def is_clean_designed(data) -> bool:\n    return (\n        getattr(data, \"voice_type\", None) == \"designed\"\n        and not getattr(data, \"preset_engine\", None)\n        and not getattr(data, \"preset_voice_id\", None)\n    )","tryCatchPattern":null,"preventionTips":["Send only the fields relevant to the chosen voice_type.","Clear preset fields client-side when the user selects 'designed'.","Build the request body from a per-voice_type schema rather than one shared object."],"tags":["profiles","designed","validation","create","mutually-exclusive"],"backgroundTag":null,"analyzedSha":"51f49dea198384b4eb6087b72c17057c6eb1c1cd","analyzedAt":"2026-08-12T16:51:42.824Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}