fix(ui): correct J/K keyboard navigation direction in Logs view#24344
fix(ui): correct J/K keyboard navigation direction in Logs view#24344NIK-TIGER-BILL wants to merge 2 commits intoBerriAI:mainfrom
Conversation
…gh logging Fixes BerriAI#24281 When proxying models like anthropic/deepseek-reasoner, certain SSE stream events contain JSON structures that the Anthropic chunk parser cannot handle (e.g. thinking blocks, extended metadata), producing: streaming_handler.py:197 - Error in _route_streaming_logging_to_handler: Expecting value: line 1 column 3 (char 2) Previously _build_complete_streaming_response only caught StopIteration / StopAsyncIteration from convert_str_chunk_to_generic_chunk. Any other exception (json.JSONDecodeError, KeyError, …) propagated all the way up and was silently swallowed by the broad except in _route_streaming_logging_to_handler — but not before emitting a noisy ERROR-level log on every request. Fix: add an except-Exception guard around the per-event conversion loop so that individual unparseable events are skipped with a DEBUG-level log while all valid events in the same stream are still processed and logged correctly. The overall logging call is no longer aborted by a single bad event.
Fixes BerriAI#24279 J and K were mapped to the wrong navigation functions: - Pressing J called selectPreviousLog() (moved UP to newer) - Pressing K called selectNextLog() (moved DOWN to older) This is the opposite of the UI buttons and of standard vim-style navigation where J = down (older entry in newest-first list) and K = up (newer entry). Fix: swap the J and K cases so they match both the UI buttons and vim convention: - J → selectNextLog() (moves down to the next / older log) - K → selectPreviousLog() (moves up to the previous / newer log)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
NIK-TIGER-BILL seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Greptile SummaryThis PR contains two unrelated fixes bundled together: a one-line keyboard navigation inversion fix in the Logs view UI, and a resilience improvement in the Anthropic SSE passthrough logging handler.
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/useKeyboardNavigation.ts | Correct one-line fix swapping selectNextLog/selectPreviousLog in the J/K keyboard handlers to match vim conventions and existing UI button behaviour. Comment and JSDoc updated to match. No issues found. |
| litellm/proxy/pass_through_endpoints/llm_provider_handlers/anthropic_passthrough_logging_handler.py | Adds a catch-all except Exception handler to tolerate malformed SSE events from non-standard Anthropic pass-through models. The intent is sound, but the overly broad exception type risks silently masking genuine parsing regressions, and debug-level logging makes the failures invisible in production. |
Sequence Diagram
sequenceDiagram
participant User as User (keyboard)
participant Hook as useKeyboardNavigation
participant Drawer as LogDetailsDrawer
User->>Hook: keydown "j" / "J"
Hook->>Hook: selectNextLog() [index + 1]
Hook->>Drawer: onSelectLog(allLogs[currentIndex + 1])
Drawer-->>User: Show older log ↓
User->>Hook: keydown "k" / "K"
Hook->>Hook: selectPreviousLog() [index - 1]
Hook->>Drawer: onSelectLog(allLogs[currentIndex - 1])
Drawer-->>User: Show newer log ↑
User->>Hook: keydown "Escape"
Hook->>Drawer: onClose()
Drawer-->>User: Drawer closed
Last reviewed commit: "fix(ui): correct J/K..."
| 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 |
There was a problem hiding this comment.
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,
)
continueThis 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.
Problem
Closes #24279
In the Logs view side panel,
JandKkeyboard shortcuts navigate in the opposite direction compared to the UI buttons.JkeyKkeyRoot Cause
In
useKeyboardNavigation.tsthe switch cases were swapped:Jis the vim-convention key for moving down (to older entries in a newest-first list) andKfor moving up (to newer entries). The UI buttons already implement this correctly; only the keyboard handler was inverted.Solution
Swap the handler calls so keyboard behaviour matches the UI buttons and vim convention:
Testing
J→ navigates to the next (older) log ✓K→ navigates to the previous (newer) log ✓