Fix Gemini 429 log truncation: escape braces in response body
Browse filesHF Space log system parses { as JSON object start, truncating the
error message. Escape { and } in all Gemini 429/error log lines so
the full response body is visible in logs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- src/soci/engine/llm.py +8 -4
src/soci/engine/llm.py
CHANGED
|
@@ -729,10 +729,12 @@ class GeminiClient:
|
|
| 729 |
self._rate_limited_until = time.monotonic() + wait
|
| 730 |
logger.warning(f"Gemini quota exhausted for {wait:.0f}s")
|
| 731 |
return ""
|
| 732 |
-
|
|
|
|
| 733 |
await asyncio.sleep(wait)
|
| 734 |
else:
|
| 735 |
-
|
|
|
|
| 736 |
if attempt == self.max_retries - 1:
|
| 737 |
return ""
|
| 738 |
await asyncio.sleep(1)
|
|
@@ -793,10 +795,12 @@ class GeminiClient:
|
|
| 793 |
self._rate_limited_until = time.monotonic() + wait
|
| 794 |
logger.warning(f"Gemini quota exhausted for {wait:.0f}s")
|
| 795 |
return {}
|
| 796 |
-
|
|
|
|
| 797 |
await asyncio.sleep(wait)
|
| 798 |
else:
|
| 799 |
-
|
|
|
|
| 800 |
if attempt == self.max_retries - 1:
|
| 801 |
return {}
|
| 802 |
await asyncio.sleep(1)
|
|
|
|
| 729 |
self._rate_limited_until = time.monotonic() + wait
|
| 730 |
logger.warning(f"Gemini quota exhausted for {wait:.0f}s")
|
| 731 |
return ""
|
| 732 |
+
body = e.response.text[:200].replace("{", "(").replace("}", ")")
|
| 733 |
+
logger.warning(f"Gemini 429: {body} — waiting {wait}s")
|
| 734 |
await asyncio.sleep(wait)
|
| 735 |
else:
|
| 736 |
+
body = e.response.text[:200].replace("{", "(").replace("}", ")")
|
| 737 |
+
logger.error(f"Gemini HTTP error: {e.response.status_code} {body}")
|
| 738 |
if attempt == self.max_retries - 1:
|
| 739 |
return ""
|
| 740 |
await asyncio.sleep(1)
|
|
|
|
| 795 |
self._rate_limited_until = time.monotonic() + wait
|
| 796 |
logger.warning(f"Gemini quota exhausted for {wait:.0f}s")
|
| 797 |
return {}
|
| 798 |
+
body = e.response.text[:200].replace("{", "(").replace("}", ")")
|
| 799 |
+
logger.warning(f"Gemini 429 (json): {body} — waiting {wait}s")
|
| 800 |
await asyncio.sleep(wait)
|
| 801 |
else:
|
| 802 |
+
body = e.response.text[:200].replace("{", "(").replace("}", ")")
|
| 803 |
+
logger.error(f"Gemini JSON error: {e.response.status_code} {body}")
|
| 804 |
if attempt == self.max_retries - 1:
|
| 805 |
return {}
|
| 806 |
await asyncio.sleep(1)
|