[PR #213] [CLOSED] Google RPC fix and enhancement #216

Closed
opened 2026-02-13 17:28:07 -06:00 by mirrors · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/HanaokaYuzu/Gemini-API/pull/213
Author: @ww2283
Created: 1/14/2026
Status: Closed

Base: masterHead: master


📝 Commits (2)

  • 8c370a2 fix: improve security by enabling SSL verification and restricting cookie file permissions
  • 111a441 fix: handle multi-line JSON chunks in extract_json_from_response() - Fixes #1

📊 Changes

4 files changed (+546 additions, -4 deletions)

View changed files

📝 src/gemini_webapi/utils/get_access_token.py (+1 -2)
📝 src/gemini_webapi/utils/parsing.py (+135 -2)
📝 src/gemini_webapi/utils/rotate_1psidts.py (+1 -0)
tests/test_parsing.py (+409 -0)

📄 Description

Summary

  • Google RPC streaming format uses length markers followed by JSON chunks that may span multiple lines
  • The previous implementation used splitlines() which broke multi-line JSON and incorrectly returned numeric length markers
  • Added length-marker parsing with bracket-balanced fallback
  • Added JSON string sanitization for raw newlines
  • Maintains backward compatibility with line-by-line fallback

Changes

  • src/gemini_webapi/utils/parsing.py: Added _parse_with_length_markers(), _sanitize_json_newlines(), _maybe_unwrap()
  • tests/test_parsing.py: 23 unit tests for parsing module

Test Plan

  • Unit tests (23/23 passing)
  • Real API tests with simple requests
  • Real API tests with PDF file attachments (large responses)
  • Verified response matches web interface

Fixes #212


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/HanaokaYuzu/Gemini-API/pull/213 **Author:** [@ww2283](https://github.com/ww2283) **Created:** 1/14/2026 **Status:** ❌ Closed **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (2) - [`8c370a2`](https://github.com/HanaokaYuzu/Gemini-API/commit/8c370a2735b11255e9c9e7655666ff05f29890c7) fix: improve security by enabling SSL verification and restricting cookie file permissions - [`111a441`](https://github.com/HanaokaYuzu/Gemini-API/commit/111a441472afe3f383f999ba69a6b27137d66996) fix: handle multi-line JSON chunks in extract_json_from_response() - Fixes #1 ### 📊 Changes **4 files changed** (+546 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `src/gemini_webapi/utils/get_access_token.py` (+1 -2) 📝 `src/gemini_webapi/utils/parsing.py` (+135 -2) 📝 `src/gemini_webapi/utils/rotate_1psidts.py` (+1 -0) ➕ `tests/test_parsing.py` (+409 -0) </details> ### 📄 Description ## Summary - Google RPC streaming format uses length markers followed by JSON chunks that may span multiple lines - The previous implementation used `splitlines()` which broke multi-line JSON and incorrectly returned numeric length markers - Added length-marker parsing with bracket-balanced fallback - Added JSON string sanitization for raw newlines - Maintains backward compatibility with line-by-line fallback ## Changes - `src/gemini_webapi/utils/parsing.py`: Added `_parse_with_length_markers()`, `_sanitize_json_newlines()`, `_maybe_unwrap()` - `tests/test_parsing.py`: 23 unit tests for parsing module ## Test Plan - [x] Unit tests (23/23 passing) - [x] Real API tests with simple requests - [x] Real API tests with PDF file attachments (large responses) - [x] Verified response matches web interface Fixes #212 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
mirrors 2026-02-13 17:28:07 -06:00
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#216
No description provided.