Skip to content

🔴 [Bug] Silent exception swallowing in get_ai_insight() hides Gemini API errors #9

Description

@AkshatRaj00

Bug Report

File: app.pyget_ai_insight() function

Problem

All exceptions in the Gemini API call are silently caught and return an empty string. This makes it impossible to debug issues like:

  • Invalid API key
  • Rate limiting (429 errors)
  • Network timeouts
  • Model deprecation

Current Code

except Exception:
    return ""  # Silent failure - user sees nothing, dev sees nothing

Expected Fix

except google.api_core.exceptions.ResourceExhausted:
    st.warning("⚠️ Gemini API rate limit reached. Try again in a moment.")
    return ""
except google.api_core.exceptions.InvalidArgument as e:
    st.error(f"Invalid Gemini API key or request: {e}")
    return ""
except Exception as e:
    logger.error(f"Gemini insight failed: {type(e).__name__}: {e}")
    st.caption(f"⚠️ AI insight unavailable: {type(e).__name__}")
    return ""

Impact

  • Users get no feedback when AI insight fails
  • Developers cannot debug production errors

Severity

🔴 Critical — production debugging is impossible

bug gemini error-handling

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions