From 1a571b01c7a18758975e4224ce4cfdecb637a9dd Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 7 Jan 2026 13:39:15 -0600 Subject: [PATCH] Add verbose exception debugging for empty error messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Log full exception details: type, module, str, repr, args, and __dict__ to diagnose why Gemini errors are producing empty messages. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- backend/app/services/llm_service.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/backend/app/services/llm_service.py b/backend/app/services/llm_service.py index ebbdaf36..19e26fe2 100755 --- a/backend/app/services/llm_service.py +++ b/backend/app/services/llm_service.py @@ -300,9 +300,17 @@ class LLMService: except Exception as e: # Fallback for OpenAI and other non-Google errors last_error = e - error_message = str(e).lower() + # Debug: capture full exception details + exc_type = type(e).__name__ + exc_module = type(e).__module__ + exc_str = str(e) + exc_repr = repr(e) + exc_args = getattr(e, 'args', ()) + exc_dict = getattr(e, '__dict__', {}) - logger.warning(f"LLM attempt {attempt_num}/{max_retries} failed: {str(e)}") + logger.warning(f"LLM attempt {attempt_num}/{max_retries} failed - Type: {exc_module}.{exc_type}, str: '{exc_str}', repr: {exc_repr}, args: {exc_args}, dict: {exc_dict}") + + error_message = exc_str.lower() if exc_str else exc_repr.lower() # Check if this is a retryable error (API internal errors, rate limiting, etc.) if ("500" in error_message or @@ -331,7 +339,8 @@ class LLMService: error_msg = getattr(last_error, 'message', str(last_error)) or str(last_error) or repr(last_error) error_detail = f"[Google API {error_code}] {error_msg}" else: - error_detail = str(last_error) + # Use repr if str is empty + error_detail = str(last_error) or repr(last_error) or f"{type(last_error).__module__}.{type(last_error).__name__}: {getattr(last_error, 'args', ())}" logger.error(f"LLM content generation failed after {max_retries} attempts. Final error: {error_detail}") raise LLMServiceError(f"Error generating content: {error_detail}")