From 8bbdda47ad100b719e2d68b16d6e110cad3c67f8 Mon Sep 17 00:00:00 2001 From: yucheng Date: Wed, 23 Sep 2026 08:05:04 +0000 Subject: [PATCH] refactor(langfuse): give the 413 split helpers a single explicit return path Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/integrations/langfuse/langfuse_sdk.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/litellm/integrations/langfuse/langfuse_sdk.py b/litellm/integrations/langfuse/langfuse_sdk.py index b0d0048fde1..a43ab560f9c 100644 --- a/litellm/integrations/langfuse/langfuse_sdk.py +++ b/litellm/integrations/langfuse/langfuse_sdk.py @@ -588,12 +588,11 @@ class _Halving: def _smaller(batch: _Batch) -> tuple[_Batch, ...]: """What to send after a 413: the two halves of a batch, or a single span with its largest field truncated.""" - match batch: - case (only,): - truncated: Final = _truncated(only) - return () if truncated is None else ((truncated,),) - case _: - return batch[: len(batch) // 2], batch[len(batch) // 2 :] + if len(batch) != 1: + return batch[: len(batch) // 2], batch[len(batch) // 2 :] + (only,) = batch + truncated: Final = _truncated(only) + return () if truncated is None else ((truncated,),) def _in_group(key: str, group: tuple[str, ...]) -> bool: @@ -717,14 +716,13 @@ class LangfuseSpanExporter(SpanExporter): self.endpoint, _TRUNCATION_MARKER, ) - return "too_large" case _: verbose_logger.warning( "Langfuse rejected a %d byte export of %d spans as too large, resending in halves", len(body), len(batch), ) - return "too_large" + return "too_large" def _send(self, body: bytes) -> _ExportOutcome: for delay in self.delays: