Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,20 @@ def _build_complete_streaming_response(

except (StopIteration, StopAsyncIteration):
break
except Exception as e:
# Some models (e.g. anthropic/deepseek-reasoner) may emit SSE
# events with non-standard JSON or extra fields that the
# Anthropic chunk parser cannot handle. Silently skip
# individual malformed events so that valid events in the same
# stream are still logged rather than dropping the entire
# logging call with an unhandled JSONDecodeError.
verbose_proxy_logger.debug(
"Skipping unparseable Anthropic SSE event during passthrough "
"logging. Error: %s. Event (truncated): %.200s",
str(e),
event_str,
)
continue
Comment on lines +293 to +306
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Overly broad exception handler may swallow genuine bugs

The catch-all except Exception will silently suppress any exception thrown by convert_str_chunk_to_generic_chunk — including AttributeError, TypeError, MemoryError, and other errors that indicate real bugs in the conversion logic rather than malformed SSE payloads.

Additionally, the failure is logged only at debug level, meaning silent data-loss in production will be invisible unless a user explicitly enables debug logging. Consider narrowing to the specific parsing-related exceptions that can be expected from malformed SSE events and raising the log level to warning so operators can detect systematic parsing failures:

except (StopIteration, StopAsyncIteration):
    break
except (json.JSONDecodeError, ValueError, KeyError) as e:
    # Some models (e.g. anthropic/deepseek-reasoner) may emit SSE
    # events with non-standard JSON or extra fields that the
    # Anthropic chunk parser cannot handle.  Silently skip
    # individual malformed events so that valid events in the same
    # stream are still logged rather than dropping the entire
    # logging call with an unhandled JSONDecodeError.
    verbose_proxy_logger.warning(
        "Skipping unparseable Anthropic SSE event during passthrough "
        "logging. Error: %s. Event (truncated): %.200s",
        str(e),
        event_str,
    )
    continue

This way, unexpected errors (e.g. regressions in the iterator logic) still propagate and are surfaced, while known parsing failures are handled gracefully and visible at warning level in production logs.


complete_streaming_response = litellm.stream_chunk_builder(
chunks=all_openai_chunks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ interface UseKeyboardNavigationProps {
* Handles J/K for next/previous and Escape for close.
*
* Keyboard shortcuts:
* - J: Navigate to previous log (up)
* - K: Navigate to next log (down)
* - J: Navigate to next log (down / older, following vim conventions)
* - K: Navigate to previous log (up / newer, following vim conventions)
* - Escape: Close drawer
*/
export function useKeyboardNavigation({
Expand All @@ -41,11 +41,11 @@ export function useKeyboardNavigation({
break;
case KEY_J_LOWER:
case KEY_J_UPPER:
selectPreviousLog();
selectNextLog();
break;
case KEY_K_LOWER:
case KEY_K_UPPER:
selectNextLog();
selectPreviousLog();
break;
}
};
Expand Down