mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-08 08:08:37 +00:00
`GenAIEventRecorder.record_operation_exception` built the `Event` without a `body`, so `Event.body` defaulted to `None`. The OTLP protobuf encoder has no representation for `None` — `_encode_value` raises `Invalid type <class 'NoneType'> of value None` while serialising the batch. `BatchLogRecordProcessor._export_batch` catches the exception, clears the records, and returns `idx` as if they were exported. The result: one unencodable record destroys the entire batch, with no crash, no retry, and no operator signal beyond a traceback. Because `record_operation_exception` is the only emit site on the v2 logs signal, every batch on that pipeline contains only unencodable records. The logs signal never delivers anything at all — operators see GenAI exception events simply never arrive at the backend, while spans and metrics from the same proxies flow normally. The reproducer in the issue document shows 0/30-day log delivery across three real production environments running v1.95.0 / v1.96.2. This is the same root cause as the cycle 11 / #36759 fix for the v1 metrics/events path (`gen_ai.system=None`) — an OTel attribute / event field carrying a `None` that the OTLP encoder rejects. The v1 fix did not touch the v2 path: the two are in separate code trees (`litellm/integrations/opentelemetry.py` vs `litellm/integrations/otel/plumbing/events.py`) and the v2 path was byte-identical at the time of the cycle 11 work. Upstream OTel added a `None` branch to `_encode_value` in `opentelemetry-exporter-otlp-proto-common` 1.43.0. LiteLLM hard-pins `opentelemetry-api/-sdk/-exporter-otlp==1.28.0`, so as shipped this event can never be exported without a code change. Fix: pass `body=message` to the `Event` constructor. The exception message is the natural body for a WARN record and adds nothing the attributes don't already carry. The fix is one line of code plus 8 lines of comment cross-referencing the issue. Pin the fix with a new test file `tests/test_litellm/integrations/otel/test_otel_v2_event_recorder.py`: - `test_record_operation_exception_sets_non_none_body` constructs the recorder with a mocked `EventLogger`, drives the sync `record_operation_exception` call, captures the `Event` that was passed to `emit`, and asserts the body is a non-`None` string equal to the exception message. Pins the name, the `exception.type` attribute, the `exception.message` attribute, and the new body. - `test_record_operation_exception_with_stacktrace_still_sets_body` exercises the same code path with a non-`None` stacktrace and asserts the body is still set (the stacktrace goes on `exception.stacktrace`, the body is still the message). Both pins are verified to fail without the fix (`assert None is not None` — the captured `Event.body` is `None`) and pass with it. The test mocks `event_logger.emit` as a plain `MagicMock` (not `AsyncMock`) because the recorder is sync and calls `emit` without `await` — matching the issue's standalone repro and the pre-existing v2 emit site. The test docstring documents this. Fixes #36863. |
||
|---|---|---|
| .. | ||
| agent_tests | ||
| audio_tests | ||
| basic_proxy_startup_tests | ||
| batches_tests | ||
| benchmarks | ||
| code_coverage_tests | ||
| documentation_tests | ||
| e2e | ||
| enterprise | ||
| guardrails_tests | ||
| image_gen_tests | ||
| integration | ||
| litellm | ||
| litellm-proxy-extras | ||
| litellm_core_utils | ||
| litellm_utils_tests | ||
| llm_responses_api_testing | ||
| llm_translation | ||
| load_tests | ||
| local_testing | ||
| logging_callback_tests | ||
| mcp_tests | ||
| multi_instance_e2e_tests | ||
| ocr_tests | ||
| old_proxy_tests/tests | ||
| openai_endpoints_tests | ||
| otel_tests | ||
| pass_through_tests | ||
| pass_through_unit_tests | ||
| proxy_admin_ui_tests | ||
| proxy_behavior | ||
| proxy_e2e_anthropic_messages_tests | ||
| proxy_migration_tests | ||
| proxy_security_tests | ||
| proxy_unit_tests | ||
| router_unit_tests | ||
| scim_tests | ||
| search_tests | ||
| spend_tracking_tests | ||
| store_model_in_db_tests | ||
| test_litellm | ||
| unified_google_tests | ||
| vector_store_tests | ||
| windows_tests | ||
| __init__.py | ||
| _fake_openai_endpoint_server.py | ||
| _flush_vcr_cache.py | ||
| _live_test_helpers.py | ||
| _openai_record_replay_proxy.py | ||
| _vcr_conftest_common.py | ||
| _vcr_redis_persister.py | ||
| _ws_vcr.py | ||
| eval_swe_bench.py | ||
| fake_openai_endpoint.py | ||
| gettysburg.wav | ||
| large_text.py | ||
| openai_batch_completions.jsonl | ||
| pyrightconfig.json | ||
| README.MD | ||
| test_anthropic_compaction_usage.py | ||
| test_budget_management.py | ||
| test_callbacks_on_proxy.py | ||
| test_config.py | ||
| test_debug_warning.py | ||
| test_default_encoding_non_root.py | ||
| test_end_users.py | ||
| test_entrypoint.py | ||
| test_fallbacks.py | ||
| test_gpt5_azure_temperature_support.py | ||
| test_health.py | ||
| test_keys.py | ||
| test_litellm_proxy_responses_config.py | ||
| test_logging.conf | ||
| test_models.py | ||
| test_new_vector_store_endpoints.py | ||
| test_openai_endpoints.py | ||
| test_organizations.py | ||
| test_otel_thread_leak.py | ||
| test_passthrough_endpoints.py | ||
| test_presidio_latency.py | ||
| test_proxy_server_non_root.py | ||
| test_ratelimit.py | ||
| test_resource_cleanup.py | ||
| test_service_logger_otel.py | ||
| test_spend_logs.py | ||
| test_team.py | ||
| test_team_logging.py | ||
| test_team_members.py | ||
| test_users.py | ||
In total litellm runs 1000+ tests
[02/20/2025] Update:
To make it easier to contribute and map what behavior is tested,
we've started mapping the litellm directory in tests/test_litellm
This folder can only run mock tests.