{"record":{"id":"979b216d0f76795c","repo":"jamiepine/voicebox","slug":"generation-not-found-979b21","errorCode":null,"errorMessage":"Generation not found","messagePattern":"Generation not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"backend/routes/effects.py","lineNumber":27,"sourceCode":"from sqlalchemy.orm import Session\n\nfrom .. import config, models\nfrom ..services import history\nfrom ..database import Generation as DBGeneration, get_db\n\nrouter = APIRouter()\n\n\n@router.post(\"/effects/preview/{generation_id}\")\nasync def preview_effects(\n    generation_id: str,\n    data: models.ApplyEffectsRequest,\n    db: Session = Depends(get_db),\n):\n    \"\"\"Apply effects to a generation's clean audio and stream back without saving.\"\"\"\n    gen = db.query(DBGeneration).filter_by(id=generation_id).first()\n    if not gen:\n        raise HTTPException(status_code=404, detail=\"Generation not found\")\n    if (gen.status or \"completed\") != \"completed\":\n        raise HTTPException(status_code=400, detail=\"Generation is not completed\")\n\n    from ..services import versions as versions_mod\n    from ..utils.effects import apply_effects, validate_effects_chain\n    from ..utils.audio import load_audio\n\n    chain_dicts = [e.model_dump() for e in data.effects_chain]\n    error = validate_effects_chain(chain_dicts)\n    if error:\n        raise HTTPException(status_code=400, detail=error)\n\n    all_versions = versions_mod.list_versions(generation_id, db)\n    clean_version = next((v for v in all_versions if v.effects_chain is None), None)\n    source_path = clean_version.audio_path if clean_version else gen.audio_path\n    resolved_source_path = config.resolve_storage_path(source_path)\n    if resolved_source_path is None or not resolved_source_path.exists():\n        raise HTTPException(status_code=404, detail=\"Source audio file not found\")","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/jamiepine/voicebox/blob/51f49dea198384b4eb6087b72c17057c6eb1c1cd/backend/routes/effects.py#L9-L45","documentation":"HTTP 404 raised by POST /effects/preview/{generation_id} when the DBGeneration lookup by id returns no row. The handler queries db.query(DBGeneration).filter_by(id=generation_id).first() and raises 404 'Generation not found' on a miss. This check runs before any status or effects validation.","triggerScenarios":"POST /effects/preview/{generation_id} with a generation_id that was never created, was deleted, or is malformed.","commonSituations":"Previewing effects for a generation from a stale list; using a clip/voice ID instead of a generation ID; generation pruned by cleanup.","solutions":["Confirm the generation_id exists in the generations list before opening the effects preview.","Copy the ID from a recent generation response, not from a cached/older one.","On 404, refresh the generations list and discard the stale reference."],"exampleFix":"// before\nawait fetch(`/effects/preview/${genId}`, { method:'POST', body: JSON.stringify(payload) });\n// after\nconst gens = await fetch('/generations').then(r => r.json());\nif (!gens.some(g => g.id === genId)) { await refreshGenerations(); return; }\nawait fetch(`/effects/preview/${genId}`, { method:'POST', body: JSON.stringify(payload) });","handlingStrategy":"validation","validationCode":"const gens = await fetch('/generations').then(r => r.json());\nif (!gens.some(g => g.id === generationId)) throw new Error('generation missing');","typeGuard":"function isGenerationList(v): v is Array<{ id: string }> { return Array.isArray(v) && v.every(g => typeof g?.id === 'string'); }","tryCatchPattern":"const r = await fetch(`/effects/preview/${generationId}`, { method:'POST', body: JSON.stringify(data) });\nif (r.status === 404) { await refreshGenerations(); }","preventionTips":["Source generation IDs from a fresh generations list.","Discard stale generation references on 404.","Avoid confusing generation IDs with clip/voice IDs."],"tags":["effects","http","not-found","fastapi"],"backgroundTag":null,"analyzedSha":"51f49dea198384b4eb6087b72c17057c6eb1c1cd","analyzedAt":"2026-08-12T16:51:42.824Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}