mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-14 09:03:16 +00:00
fix(proxy): use %-style lazy logging args in SSE error mapping
tests/unit/test_logging.py::test_logging_calls_do_not_build_their_message_eagerly flags f-string logging calls in litellm/proxy/common_request_processing.py (lines 927/937/942). Pass the values as %s arguments instead so the message is only built when the log record is emitted.
This commit is contained in:
parent
fb6cc67b8a
commit
57f7564f84
1 changed files with 4 additions and 4 deletions
|
|
@ -925,8 +925,8 @@ async def _parse_event_data_for_error(event_line: str | bytes) -> int | None:
|
|||
# original vendor code is preserved in the warning log
|
||||
# for debugging.
|
||||
verbose_proxy_logger.warning(
|
||||
f"SSE error code {error_code} is outside standard HTTP range "
|
||||
f"(100-599); mapping to 502 for failure handling"
|
||||
"SSE error code %s is outside standard HTTP range (100-599); mapping to 502 for failure handling",
|
||||
error_code,
|
||||
)
|
||||
return 502
|
||||
else:
|
||||
|
|
@ -934,12 +934,12 @@ async def _parse_event_data_for_error(event_line: str | bytes) -> int | None:
|
|||
# but keep the original behaviour of returning None while
|
||||
# emitting the diagnostic warning (preserved from the
|
||||
# original elif error_code_raw is not None: branch).
|
||||
verbose_proxy_logger.warning(f"Error has invalid or non-convertible code: {error_code}")
|
||||
verbose_proxy_logger.warning("Error has invalid or non-convertible code: %s", error_code)
|
||||
elif error_code_raw is not None:
|
||||
# error_code could not be coerced to int from the raw value
|
||||
# (e.g., a non-numeric string). Log the original raw value
|
||||
# for debugging and fall through to return None.
|
||||
verbose_proxy_logger.warning(f"Error has invalid or non-convertible code: {error_code_raw}")
|
||||
verbose_proxy_logger.warning("Error has invalid or non-convertible code: %s", error_code_raw)
|
||||
except (orjson.JSONDecodeError, json.JSONDecodeError):
|
||||
# not a known error chunk
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue