Fix google_genai integration crash when Gemini returns parts=None#1678
Fix google_genai integration crash when Gemini returns parts=None#1678alexmojaki merged 8 commits intomainfrom
Conversation
When Gemini 3 Pro returns a thinking-only response with no text or tool calls, the 'parts' field can be None. This caused a TypeError when trying to iterate over None in the SpanEventLogger.emit method. Added a simple null check to handle this case gracefully by returning an empty list when parts is None. Fixes #1675 Co-authored-by: Alex Hall <alexmojaki@users.noreply.github.com>
|
@claude make CI pass |
|
Claude encountered an error after 3m 10s —— View job Making CI Pass
|
Co-authored-by: Alex Hall <alexmojaki@users.noreply.github.com>
Deploying logfire-docs with
|
| Latest commit: |
032e9f6
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e03e4b8a.logfire-docs.pages.dev |
| Branch Preview URL: | https://claude-issue-1675-20260130-0.logfire-docs.pages.dev |
|
@claude make sure you're configured to always use pre-commit |
|
Claude finished @alexmojaki's task in 26s —— View job Pre-commit Configuration
Understood! I will run
This would have caught the import sorting issue in the previous commit. Going forward, I'll ensure pre-commit hooks pass before pushing changes. |
Co-authored-by: Alex Hall <alexmojaki@users.noreply.github.com>
|
@claude you'll forget after this session. i'm asking you to make a permanent visible change to your github config. |
|
Claude finished @alexmojaki's task in 1m 41s —— View job Pre-commit Hook Configuration
Done! Added a Changes made:
This configuration will persist across sessions and ensure I always run pre-commit checks before committing. |
Configure a PreToolUse hook that automatically runs pre-commit on staged files before any git commit command. This ensures lint and format checks pass before committing. Co-authored-by: Alex Hall <alexmojaki@users.noreply.github.com>
|
@claude that will run pre-commit twice in environments where the commit hook is installed. can you do this normally and install the git hook in your github env at the start? |
|
Claude finished @alexmojaki's task in 1m 33s —— View job Git Hook Configuration
Done! Changed the approach from manually running pre-commit before each git commit to installing the git hook at session start. What changed:
This way, pre-commit is installed as a normal git hook and only runs once when committing, avoiding the double-run issue. |
This avoids running pre-commit twice when the git hook is already installed. The SessionStart hook installs pre-commit hooks at the start of each session, then git commit naturally triggers the hook. Co-authored-by: Alex Hall <alexmojaki@users.noreply.github.com>
|
@claude fix CI |
|
Claude encountered an error after 2m 14s —— View job Fixing CI
|
There was a problem hiding this comment.
Pull request overview
This pull request fixes a crash in the google_genai integration that occurs when Gemini 3 Pro returns a thinking-only response with parts=None. The fix adds a simple null check and includes comprehensive test coverage.
Changes:
- Added conditional logic to handle
parts=Nonein the Google GenAI integration - Added test case to verify the fix works correctly
- Refactored test exporter to consolidate attribute building logic
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| logfire/_internal/integrations/google_genai.py | Added null check for parts to prevent TypeError when iterating |
| tests/otel_integrations/test_google_genai.py | Added test for parts=None scenario to prevent regression |
| logfire/_internal/exporters/test.py | Refactored to use centralized _build_attributes function, removing duplicate code |
| .claude/settings.json | Added pre-commit hooks configuration (unrelated to bug fix) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks so much! |

Summary
parts=Noneparts=NonescenarioFixes #1675
Generated with Claude Code