-
Notifications
You must be signed in to change notification settings - Fork 121
fix: correct input validation conditions in Bifrost requests #558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
Caution Review failedThe pull request is closed. 📝 WalkthroughSummary by CodeRabbit
No changes to public APIs beyond safer input handling; existing functionality remains compatible. WalkthroughUpdated nil-checks and pointer usage to avoid nil dereferences in request validators and embedding builders; removed local JSON parsing for a Bedrock tool input delta; remapped message content block types based on role/type; updated tests and fixtures to use pointer-typed inputs/configs. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Caller
participant Mux as Mux Converter
participant Resp as ResponsesMessage
Caller->>Mux: Convert(message with blocks, role)
loop for each block
alt block.Type == Text
alt role == assistant
Mux->>Resp: map -> ResponsesOutputMessageContentTypeText
else
Mux->>Resp: map -> ResponsesInputMessageContentBlockTypeText
end
else block.Type == Image
Mux->>Resp: map -> ResponsesInputMessageContentBlockTypeImage
else block.Type == File
Mux->>Resp: map -> ResponsesInputMessageContentBlockTypeFile
else block.Type == InputAudio
Mux->>Resp: map -> ResponsesInputMessageContentBlockTypeAudio
else
Mux->>Resp: keep original block.Type
end
end
note right of Mux: Block type determined from content and role before constructing ResponsesMessage
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (14)
Comment |

Summary
Fixed critical input validation logic in Bifrost's speech, transcription, and embedding requests by correcting conditional checks and updating pointer types in request structures.
Changes
SpeechRequest,SpeechStreamRequest,TranscriptionRequest, andTranscriptionStreamRequestmethods by changingreq.Input != nil || req.Input.X == ""toreq.Input == nil || req.Input.X == ""ToResponsesMessages()to ensure proper content type assignmentprocessEventBufferfunctionType of change
Affected areas
How to test
Run the test suite to verify the fixed input validation logic:
Specifically test speech, transcription, and embedding requests to ensure proper input validation.
Breaking changes
Security considerations
This PR fixes input validation logic that could have led to unexpected behavior or potential crashes when processing requests with missing or invalid inputs.
Checklist