litellm - 💡(How to fix) Fix [Bug]: False-positive DD APM error spans on every request when allow_requests_on_db_unavailable: true [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#25966Fetched 2026-04-18 05:52:45
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
labeled ×2

Error Message

Traceback (most recent call last): File "/usr/lib/python3.13/site-packages/litellm/proxy/auth/user_api_key_auth.py", line 1029, in _user_api_key_auth_builder valid_token = await get_key_object( ^^^^^^^^^^^^^^^^^^^^^ ...<6 lines>... ) ^ File "/usr/lib/python3.13/site-packages/litellm/proxy/db/log_db_metrics.py", line 99, in wrapper raise e File "/usr/lib/python3.13/site-packages/litellm/proxy/db/log_db_metrics.py", line 42, in wrapper result = await func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.13/site-packages/litellm/proxy/auth/auth_checks.py", line 2224, in get_key_object raise Exception( "No DB Connected. See - https://docs.litellm.ai/docs/proxy/virtual_keys" ) Exception: No DB Connected. See - https://docs.litellm.ai/docs/proxy/virtual_keys

Code Example

Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/litellm/proxy/auth/user_api_key_auth.py", line 1029, in _user_api_key_auth_builder
    valid_token = await get_key_object(
                  ^^^^^^^^^^^^^^^^^^^^^
                  ...<6 lines>...
                  )
                  ^
  File "/usr/lib/python3.13/site-packages/litellm/proxy/db/log_db_metrics.py", line 99, in wrapper
    raise e
  File "/usr/lib/python3.13/site-packages/litellm/proxy/db/log_db_metrics.py", line 42, in wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/proxy/auth/auth_checks.py", line 2224, in get_key_object
    raise Exception(
        "No DB Connected. See - https://docs.litellm.ai/docs/proxy/virtual_keys"
    )
Exception: No DB Connected. See - https://docs.litellm.ai/docs/proxy/virtual_keys
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

When running without a database with allow_requests_on_db_unavailable: true, every proxy request generates a false-positive litellm.proxy.auth.get_key_object_check_cache error span in Datadog APM. Requests succeed — the exception is caught and handled — but the span is still marked as errored.

Steps to Reproduce

Run litellm proxy v1.83.3-stable without a database Set general_settings.allow_requests_on_db_unavailable: true Enable Datadog APM (USE_DDTRACE=true) Make any request — every one produces an errored get_key_object_check_cache span

Relevant log output

Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/litellm/proxy/auth/user_api_key_auth.py", line 1029, in _user_api_key_auth_builder
    valid_token = await get_key_object(
                  ^^^^^^^^^^^^^^^^^^^^^
                  ...<6 lines>...
                  )
                  ^
  File "/usr/lib/python3.13/site-packages/litellm/proxy/db/log_db_metrics.py", line 99, in wrapper
    raise e
  File "/usr/lib/python3.13/site-packages/litellm/proxy/db/log_db_metrics.py", line 42, in wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/proxy/auth/auth_checks.py", line 2224, in get_key_object
    raise Exception(
        "No DB Connected. See - https://docs.litellm.ai/docs/proxy/virtual_keys"
    )
Exception: No DB Connected. See - https://docs.litellm.ai/docs/proxy/virtual_keys

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

main-v1.83.3-stable

Twitter / LinkedIn details

No response

extent analysis

TL;DR

  • The issue can be mitigated by handling the "No DB Connected" exception in a way that does not mark the Datadog APM span as errored when allow_requests_on_db_unavailable is true.

Guidance

  • Review the get_key_object function in auth_checks.py to understand how the exception is being raised and how it's affecting the APM span.
  • Consider modifying the exception handling in _user_api_key_auth_builder to distinguish between critical errors and the expected "No DB Connected" exception when allow_requests_on_db_unavailable is true.
  • Investigate Datadog APM configuration options to see if there's a way to ignore specific exceptions or error types from marking spans as errored.
  • Verify that the allow_requests_on_db_unavailable setting is correctly applied and that the proxy requests are succeeding as expected despite the errored spans.

Example

try:
    valid_token = await get_key_object(
        # ...
    )
except Exception as e:
    if "No DB Connected" in str(e) and general_settings.allow_requests_on_db_unavailable:
        # Handle the exception without marking the span as errored
        pass
    else:
        # Re-raise or handle other exceptions as before
        raise

Notes

  • This guidance assumes that the "No DB Connected" exception is expected and handled correctly by the application logic when allow_requests_on_db_unavailable is true.
  • The exact implementation details may vary depending on the specific requirements and constraints of the LiteLLM proxy application.

Recommendation

  • Apply workaround: Modify the exception handling to ignore the "No DB Connected" exception when allow_requests_on_db_unavailable is true, as this allows the application to continue functioning as intended while avoiding false-positive error reports in Datadog APM.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

litellm - 💡(How to fix) Fix [Bug]: False-positive DD APM error spans on every request when allow_requests_on_db_unavailable: true [1 participants]