Coverage for .venv/lib/python3.13/site-packages/litellm/proxy/common_utils/error_body_call_id.py: 78%

14 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-10 12:01 +0000

1from collections.abc import Mapping 

2from typing import Final 

3 

4from pydantic import TypeAdapter 

5 

6INCLUDE_CALL_ID_IN_ERROR_BODY_SETTING: Final = "include_call_id_in_error_body" 

7LITELLM_CALL_ID_BODY_KEY: Final = "litellm_call_id" 

8JSON_OBJECT: Final[TypeAdapter[dict[str, object]]] = TypeAdapter(dict[str, object]) # mutable-ok: JSONResponse input 

9 

10 

11def error_body_call_id(general_settings: Mapping[str, object], call_id: str | None) -> str | None: 

12 if general_settings.get(INCLUDE_CALL_ID_IN_ERROR_BODY_SETTING) is not True: 12 ↛ 14line 12 didn't jump to line 14 because the condition on line 12 was always true

13 return None 

14 return call_id if call_id else None 

15 

16 

17def with_call_id(error: dict[str, object], call_id: str | None) -> dict[str, object]: # mutable-ok: JSONResponse input 

18 if call_id is None: 18 ↛ 20line 18 didn't jump to line 20 because the condition on line 18 was always true

19 return error 

20 return {**error, LITELLM_CALL_ID_BODY_KEY: call_id} # mutable-ok: JSONResponse input