diff --git a/backend/api/podcast/handlers/analysis.py b/backend/api/podcast/handlers/analysis.py index b1800ec4..3131c4a3 100644 --- a/backend/api/podcast/handlers/analysis.py +++ b/backend/api/podcast/handlers/analysis.py @@ -121,22 +121,12 @@ Return JSON with: enhanced_ideas=enhanced_ideas[:3], # Ensure exactly 3 rationales=rationales[:3] # Ensure exactly 3 ) + except HTTPException: + # Re-raise HTTPExceptions (e.g., 429 subscription limit) - preserve error details + raise except Exception as exc: logger.error(f"[Podcast Enhance] Failed for user {user_id}: {exc}") - # Fallback to basic variations of original idea - base_idea = request.idea - return PodcastEnhanceIdeaResponse( - enhanced_ideas=[ - f"Expert insights on {base_idea}: A deep dive into industry trends and best practices.", - f"The human side of {base_idea}: Personal stories and real-world experiences that resonate.", - f"Modern perspectives on {base_idea}: Current trends and forward-thinking approaches." - ], - rationales=[ - "Professional approach focusing on expertise and authority", - "Storytelling approach emphasizing human connection", - "Contemporary approach highlighting current relevance" - ] - ) + raise HTTPException(status_code=500, detail=f"Enhance failed: {exc}") @router.post("/analyze", response_model=PodcastAnalyzeResponse) diff --git a/backend/api/podcast/handlers/research.py b/backend/api/podcast/handlers/research.py index 2e75405c..503d54bc 100644 --- a/backend/api/podcast/handlers/research.py +++ b/backend/api/podcast/handlers/research.py @@ -160,10 +160,11 @@ Requirements: summary = data.get("summary", "") key_insights = [PodcastResearchInsight(**insight) for insight in data.get("key_insights", [])] + except HTTPException: + raise except Exception as exc: logger.error(f"[Podcast Research] LLM Insight extraction failed: {exc}") - # Fallback to a basic summary if LLM fails - summary = f"Research completed for '{request.topic}'. Found {len(sources)} sources." + raise HTTPException(status_code=500, detail=f"Research insight extraction failed: {exc}") # Fallback: if summary is still empty (e.g. LLM returned empty string), use raw content first paragraph or basic text if not summary: diff --git a/backend/api/podcast/handlers/script.py b/backend/api/podcast/handlers/script.py index 2e2b44dd..962e1767 100644 --- a/backend/api/podcast/handlers/script.py +++ b/backend/api/podcast/handlers/script.py @@ -133,6 +133,8 @@ Guidelines: preferred_provider="huggingface", flow_type="premium_tool", ) + except HTTPException: + raise except Exception as exc: raise HTTPException(status_code=500, detail=f"Script generation failed: {exc}")