Skip to content

fix: handle panic in gemini responses stream - #723

Merged
akshaydeo merged 1 commit into
mainfrom
10-31-fix_handle_panic_in_gemini_responses_stream
Oct 31, 2025
Merged

fix: handle panic in gemini responses stream#723
akshaydeo merged 1 commit into
mainfrom
10-31-fix_handle_panic_in_gemini_responses_stream

Conversation

@TejasGhatte

@TejasGhatte TejasGhatte commented Oct 31, 2025

Copy link
Copy Markdown
Collaborator

Summary

Fix the request type assignment in responses stream and prioritize responses stream handling over chat responses in the streaming handler.

Closes #721

Changes

  • Added RequestType assignment in ToBifrostResponsesStreamResponse() to properly set the request type to ResponsesStreamRequest
  • Reordered the switch case in handleStreaming() to check for BifrostResponsesStreamResponse before BifrostChatResponse to ensure proper handling priority

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (Next.js)
  • Docs

How to test

Test streaming responses to verify the correct handling order:

# Core/Transports
go version
go test ./...

Breaking changes

  • Yes
  • No

Related issues

Fixes an issue where responses stream requests were not properly identified and could be incorrectly handled as chat responses.

Security considerations

No security implications.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@coderabbitai

coderabbitai Bot commented Oct 31, 2025

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved streaming response handling with enhanced metadata tracking for chat messages.

Walkthrough

Added a request type indicator to streaming response metadata and reorganized the switch case evaluation order for streaming chunk handling in the bifrost HTTP transport layer without altering functional behavior.

Changes

Cohort / File(s) Summary
Streaming Response Metadata
core/schemas/mux.go
Added assignment of ResponsesStreamRequest to streamResp.ExtraFields.RequestType in the ToBifrostResponsesStreamResponse function to include request type information in streaming responses.
HTTP Transport Handler
transports/bifrost-http/integrations/utils.go
Reordered the BifrostChatResponse case within the streaming chunk switch statement; functionality unchanged, chat responses continue to route through ChatStreamResponseConverter.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Single field assignment in response construction
  • Switch case reordering with no functional changes
  • No new logic or control flow modifications introduced

Poem

🐰 A tiny tweak, a metadata flag,
Switch case reordered, no logic lag,
Request types flow through streams so bright,
Bifrost responses, organized right!
Hop, hop!

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The pull request title states "fix: handle panic in gemini responses stream," but based on the actual code changes and PR description, the primary modifications involve adding a RequestType assignment in ToBifrostResponsesStreamResponse() and reordering a switch case in the streaming handler to prioritize BifrostResponsesStreamResponse over BifrostChatResponse. The title emphasizes "panic handling," which does not appear in the changeset or in the PR objectives. Instead, the fix addresses request type identification and handling priority to prevent responses-stream requests from being misidentified as chat responses. The title should be revised to accurately reflect the actual changes, such as "fix: set request type and prioritize responses stream handling" or "fix: correct request type assignment and response handling order." This would better communicate the core purpose of the PR and avoid misleading reviewers about the nature of the fix.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed The pull request description is well-structured and comprehensively addresses all major sections of the required template. It includes a clear summary of the bug fix purpose, specific changes with rationale, appropriate type of change and affected areas selections, testing instructions with command examples, explicit breaking changes declaration, related issue reference, security considerations, and a completed checklist confirming the contributor followed contributing guidelines. The description directly maps to the template requirements and provides sufficient context for understanding the changes made across both Core (Go) and Transports files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 10-31-fix_handle_panic_in_gemini_responses_stream

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@TejasGhatte
TejasGhatte marked this pull request as ready for review October 31, 2025 03:49
@akshaydeo
akshaydeo merged commit e4c45fa into main Oct 31, 2025
4 checks passed
@akshaydeo
akshaydeo deleted the 10-31-fix_handle_panic_in_gemini_responses_stream branch October 31, 2025 04:00
akshaydeo added a commit that referenced this pull request Nov 17, 2025
…_responses_stream

fix: handle panic in gemini responses stream
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Gemini with OpenAI endpoint panics when streaming

2 participants