litellm/litellm/llms/infinity/common_utils.py
Ninaad R. Rao ee676784b7 fix(infinity): don't share a mutable default dict across InfinityError instances
InfinityError.__init__ defaulted headers to a mutable {} dict, created
once at function-definition time and shared by every InfinityError
raised without an explicit headers= argument (both real call sites in
litellm/llms/infinity/embedding/transformation.py and
litellm/llms/infinity/rerank/transformation.py omit it). Mutating one
instance's .headers would silently leak into every other
default-constructed InfinityError.

Default to None instead, matching the same pattern already used by
BaseLLMException.

Fixes #38909
2026-08-30 18:54:10 +00:00

18 lines
747 B
Python

import httpx
from litellm.llms.base_llm.chat.transformation import BaseLLMException
class InfinityError(BaseLLMException):
def __init__(self, status_code: int, message: str, headers: dict | httpx.Headers | None = None):
self.status_code = status_code
self.message = message
self.request = httpx.Request(method="POST", url="https://github.com/michaelfeil/infinity")
self.response = httpx.Response(status_code=status_code, request=self.request)
super().__init__(
status_code=status_code,
message=message,
request=self.request,
response=self.response,
headers=headers,
) # Call the base class constructor with the parameters it needs