Parsing Error (IndexError & Invalid Response) #112

Closed
opened 2026-02-13 17:27:52 -06:00 by mirrors · 4 comments
Owner

Originally created by @tminh159 on GitHub (Nov 25, 2025).

Logs:
| DEBUG | gemini_webapi.utils.parsing:get_nested_value:32 - IndexError: parsing failed at path [2] (index 0, key '2') while attempting to get value from ['di', 4168]
| DEBUG | gemini_webapi.utils.parsing:get_nested_value:32 - IndexError: parsing failed at path [0, 5, 2, 0, 1, 0] (index 2, key '2') while attempting to get value from [13]
| DEBUG | gemini_webapi.client:generate_content:407 - Invalid response: )]}'
[["wrb.fr",null,null,null,null,[13]],["di",4168],["af.httprm",4168,"-7853133795714790678",48]]

...

Traceback (most recent call last):
File "client.py", line 383, in generate_content
match ErrorCode(error_code):
^^^^^^^^^^^^^^^^^^^^^
ValueError: -1 is not a valid ErrorCode

Originally created by @tminh159 on GitHub (Nov 25, 2025). Logs: | DEBUG | gemini_webapi.utils.parsing:get_nested_value:32 - IndexError: parsing failed at path [2] (index 0, key '2') while attempting to get value from `['di', 4168]` | DEBUG | gemini_webapi.utils.parsing:get_nested_value:32 - IndexError: parsing failed at path [0, 5, 2, 0, 1, 0] (index 2, key '2') while attempting to get value from `[13]` | DEBUG | gemini_webapi.client:generate_content:407 - Invalid response: )]}' [["[wrb.fr](http://wrb.fr/)",null,null,null,null,[13]],["di",4168],["af.httprm",4168,"-7853133795714790678",48]] ... Traceback (most recent call last): File "[client.py](http://client.py/)", line 383, in generate_content match ErrorCode(error_code): ^^^^^^^^^^^^^^^^^^^^^ ValueError: -1 is not a valid ErrorCode
mirrors 2026-02-13 17:27:52 -06:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@wangjh9712 commented on GitHub (Nov 26, 2025):

+1 same

gemini2api  | 2025-11-26 05:32:33.799 | DEBUG    | gemini_webapi.utils.parsing:get_nested_value:32 - IndexError: parsing failed at path [37, 0, 0] (index 0, key '37') while attempting to get value from `['rc_ffdcad59713c5ed9', ['I\'m sorry, I don\'t understand the request "test."\n\nHow can I help you today? Would you like me to find some information, generate some text, or something else?'], None...`
gemini2api  | 2025-11-26 05:32:33.800 | DEBUG    | gemini_webapi.utils.parsing:get_nested_value:32 - IndexError: parsing failed at path [12, 7, 0] (index 2, key '0') while attempting to get value from `[]`
@wangjh9712 commented on GitHub (Nov 26, 2025): +1 same ``` gemini2api | 2025-11-26 05:32:33.799 | DEBUG | gemini_webapi.utils.parsing:get_nested_value:32 - IndexError: parsing failed at path [37, 0, 0] (index 0, key '37') while attempting to get value from `['rc_ffdcad59713c5ed9', ['I\'m sorry, I don\'t understand the request "test."\n\nHow can I help you today? Would you like me to find some information, generate some text, or something else?'], None...` gemini2api | 2025-11-26 05:32:33.800 | DEBUG | gemini_webapi.utils.parsing:get_nested_value:32 - IndexError: parsing failed at path [12, 7, 0] (index 2, key '0') while attempting to get value from `[]` ```
Author
Owner

@faithleysath commented on GitHub (Nov 26, 2025):

paste your code that can reproduce error please, that will be great help.

@faithleysath commented on GitHub (Nov 26, 2025): paste your code that can reproduce error please, that will be great help.
Author
Owner

@tminh159 commented on GitHub (Nov 26, 2025):

Some errors in the log aren’t reliably reproducible, even when using the same code, prompt, cookie, model, etc. Depend on the time of the day, I guess. But the IndexError never fails to appear.

import asyncio
import os
from dotenv import load_dotenv
from gemini_webapi import GeminiClient

load_dotenv()

async def main():
    psid = os.getenv("GEMINI_1PSID")
    psidts = os.getenv("GEMINI_1PSIDTS")

    if not psid or not psidts:
        print("Please ensure GEMINI_1PSID and GEMINI_1PSIDTS are in your .env file")
        return

    client = GeminiClient(psid, psidts)
    await client.init()
    print("--- Client Initialized ---")

    try:
        response = await client.generate_content(
            "Hello", 
            model="gemini-3.0-pro"
        )
        print("Response:", response.text)

    except Exception as e:
        print(f"\nERROR\n{e}")

if __name__ == "__main__":
    asyncio.run(main())
@tminh159 commented on GitHub (Nov 26, 2025): Some errors in the log aren’t reliably reproducible, even when using the same code, prompt, cookie, model, etc. Depend on the time of the day, I guess. But the IndexError never fails to appear. ``` import asyncio import os from dotenv import load_dotenv from gemini_webapi import GeminiClient load_dotenv() async def main(): psid = os.getenv("GEMINI_1PSID") psidts = os.getenv("GEMINI_1PSIDTS") if not psid or not psidts: print("Please ensure GEMINI_1PSID and GEMINI_1PSIDTS are in your .env file") return client = GeminiClient(psid, psidts) await client.init() print("--- Client Initialized ---") try: response = await client.generate_content( "Hello", model="gemini-3.0-pro" ) print("Response:", response.text) except Exception as e: print(f"\nERROR\n{e}") if __name__ == "__main__": asyncio.run(main()) ```
Author
Owner

@HanaokaYuzu commented on GitHub (Nov 26, 2025):

Sometimes generating content requests will fail with no valid response body and the reason is still not clear. It could be caused by server/network/frequency/account status or anything. If it just happens seldomly and randomly, please try implementing a retry logic in your code (this package will automatically retry for at most twice if error occurs, but just in case).

@wangjh9712 Please ignore those debug logs of IndexError. They just means your generation result is missing some of components (thoughts, generated image, etc.) and is an expected behavior. Like when you ask 1+1=? there won't be generated images in the response.

@HanaokaYuzu commented on GitHub (Nov 26, 2025): Sometimes generating content requests will fail with no valid response body and the reason is still not clear. It could be caused by server/network/frequency/account status or anything. If it just happens seldomly and randomly, please try implementing a retry logic in your code (this package will automatically retry for at most twice if error occurs, but just in case). @wangjh9712 Please ignore those debug logs of IndexError. They just means your generation result is missing some of components (thoughts, generated image, etc.) and is an expected behavior. Like when you ask 1+1=? there won't be generated images in the response.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mirrors/Gemini-API#112
No description provided.