From 249936d3c777f8885f610a9fcf6e28ddd2e0eac1 Mon Sep 17 00:00:00 2001 From: "juancarlos.cavero" Date: Mon, 9 Mar 2026 18:13:17 +0100 Subject: [PATCH] Fix silent thumbnail generation failure and switch to gemini-3.1-flash Thumbnail generation errors were silently swallowed, returning an empty 200 response and leaving the UI stuck on "Your thumbnails will appear here". Now surfaces actual error messages to the user. Switched model from gemini-3-pro-image-preview to gemini-3.1-flash-image-preview. Co-Authored-By: Claude Opus 4.6 --- app.py | 5 +++++ dashboard/src/components/ThumbnailStudio.jsx | 9 ++++++--- thumbnail.py | 7 ++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index 57983bd..dbe73ff 100644 --- a/app.py +++ b/app.py @@ -1234,8 +1234,13 @@ async def thumbnail_generate( video_context ) + if not thumbnails: + raise HTTPException(status_code=500, detail="Thumbnail generation failed. Please check your Gemini API key has access to image generation (gemini-3.1-flash-image-preview model).") + return {"thumbnails": thumbnails} + except HTTPException: + raise except Exception as e: print(f"❌ Thumbnail Generate Error: {e}") raise HTTPException(status_code=500, detail=str(e)) diff --git a/dashboard/src/components/ThumbnailStudio.jsx b/dashboard/src/components/ThumbnailStudio.jsx index 5d99249..5663972 100644 --- a/dashboard/src/components/ThumbnailStudio.jsx +++ b/dashboard/src/components/ThumbnailStudio.jsx @@ -298,12 +298,15 @@ export default function ThumbnailStudio({ geminiApiKey, uploadPostKey, uploadUse }); if (!res.ok) { - const err = await res.text(); - throw new Error(err); + const errData = await res.json().catch(() => null); + throw new Error(errData?.detail || `Server error ${res.status}`); } const data = await res.json(); - setGeneratedThumbnails(data.thumbnails || []); + if (!data.thumbnails || data.thumbnails.length === 0) { + throw new Error('No thumbnails were generated. Your Gemini API key may not have access to image generation.'); + } + setGeneratedThumbnails(data.thumbnails); } catch (e) { alert(`Generation failed: ${e.message}`); } finally { diff --git a/thumbnail.py b/thumbnail.py index f913e5b..e9cd4d5 100644 --- a/thumbnail.py +++ b/thumbnail.py @@ -236,11 +236,12 @@ DESIGN REQUIREMENTS: prompt_parts.append(text_prompt) thumbnails = [] + last_error = None for i in range(count): print(f"🎨 [Thumbnail] Generating thumbnail {i + 1}/{count}...") try: response = client.models.generate_content( - model="gemini-3-pro-image-preview", + model="gemini-3.1-flash-image-preview", contents=prompt_parts, config=types.GenerateContentConfig( response_modalities=["TEXT", "IMAGE"], @@ -263,8 +264,12 @@ DESIGN REQUIREMENTS: break except Exception as e: + last_error = str(e) print(f"❌ [Thumbnail] Generation {i + 1} failed: {e}") + if not thumbnails and last_error: + raise RuntimeError(f"All thumbnail generations failed. Last error: {last_error}") + return thumbnails