Fix IndexError on empty tool_calls list in proxy convert#68
Open
hobostay wants to merge 1 commit into
Open
Conversation
`tool_calls_to_openai()` and `tool_calls_to_sse_events()` both access `tool_calls[0]` without checking if the list is empty. If an upstream filtering step removes all tool calls, this raises an unhandled IndexError that crashes the proxy's response serialization with a 500 error. Add early-return guards that fall back to the corresponding text response helpers when the list is empty. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tool_calls_to_openai()andtool_calls_to_sse_events()both accesstool_calls[0]without checking if the list is emptyIndexErrorImpact
tool_callslist would crash the proxy's response serialization with a 500 error instead of gracefully returning an empty responseTest plan
tool_calls_to_openai([])and verify it returns a valid response without IndexErrortool_calls_to_sse_events([])and verify it returns valid SSE events without IndexError🤖 Generated with Claude Code