mirror of
https://github.com/HanaokaYuzu/Gemini-API.git
synced 2026-04-12 04:19:46 -06:00
[BUG] Bare Exception() raised with no message during response parsing, making debugging impossible #136
Labels
No labels
advanced
advanced
bug
dependencies
discussion
documentation
duplicate
enhancement
good first issue
help wanted
invalid
model
pull-request
question
unreproducible
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mirrors/Gemini-API#136
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ww2283 on GitHub (Jan 14, 2026).
Description:
When response parsing fails in generate_content(), the library raises bare Exception() with no message, making it impossible to diagnose what went wrong.
Observed Behavior:
When calling chat.send_message(), the request succeeds (chat session appears in Gemini WebUI), but the response parsing fails silently:
try:
response = await chat.send_message(prompt, ...)
except Exception as e:
print(f"Error: {e}") # Prints: "Error: " (empty!)
print(f"Type: {type(e)}") # Prints: <class 'Exception'>
The exception has no message, providing zero diagnostic information.
Root Cause:
In client.py, there are bare raise Exception statements with no message:
Line 375-376:
if not body:
raise Exception # No message!
Line 401-402:
case _:
raise Exception # No message!
Expected Behavior:
All exceptions should include diagnostic information:
if not body:
raise GeminiError("Response body is empty - parsing failed")
case _:
raise GeminiError(f"Unknown error code: {e_c}")
Impact:
Environment:
Trigger condition:
Sending a message with file attachments (2-3 files, ~10-20KB each) to gemini-3.0-pro.
The request succeeds server-side (visible in Gemini WebUI as a new chat session),
but the response parsing fails silently.
Debug output observed:
gemini_webapi.utils.parsing:get_nested_value - Safe navigation: path [4] ended at index 0 (key '4'), returning default.
Hypothesis:
When Gemini 3.0 Pro uses extended "thinking" time (especially with file analysis),
the response structure may differ from expected format - specifically, the output
may not be at index
[4]where the parser expects it:When this fails, body stays empty, triggering the bare raise Exception.
Suggested Fix:
Replace all bare raise Exception with descriptive raise GeminiError("...") including:
@HanaokaYuzu commented on GitHub (Feb 4, 2026):
Hey, could you please help to check if this behavior persists in the latest version?
@ww2283 commented on GitHub (Feb 4, 2026):
Ok I will let you know in about 2 days; I might be slower in validating this on the newer code because my usage are pointing to my fork now. Once I switch and test I will let you know.