BerriAI/litellm · error · HTTPException

Failed to fetch distinct user agent tags: {e}

Error message

Failed to fetch distinct user agent tags: {e}

What it means

HTTPException wrapping any unexpected exception thrown while querying LiteLLM_DailyTagSpend for distinct user-agent tags (bad SQL, Prisma failure, schema mismatch, invalid rows). The original exception text is embedded; the distinct-tags listing endpoint fails rather than returning partial data.

Source

Thrown at litellm/proxy/management_endpoints/user_agent_analytics_endpoints.py:207

        sql_query: Final = f"""
        SELECT 
            dts.tag,
            COUNT(*) as usage_count
        FROM "LiteLLM_DailyTagSpend" dts
        WHERE dts.tag LIKE 'User-Agent:%' OR dts.tag NOT LIKE '%:%'
        GROUP BY dts.tag
        ORDER BY usage_count DESC
        LIMIT {MAX_TAGS}
        """

        db_response: Final = _DISTINCT_TAG_ROWS.validate_python(await _query_raw(prisma_client, sql_query))

        results: Final = [DistinctTagResponse(tag=row.tag) for row in db_response]

        return DistinctTagsResponse(results=results)

    except Exception as e:
        raise HTTPException(
            status_code=500,
            detail=f"Failed to fetch distinct user agent tags: {e}",
        )


@router.get(
    "/tag/dau",
    response_model=ActiveUsersAnalyticsResponse,
    tags=["tag management", "user agent analytics"],
    dependencies=[Depends(user_api_key_auth)],
)
async def get_daily_active_users(
    tag_filter: str | None = Query(
        default=None,
        description="Filter by specific tag (optional)",
    ),
    tag_filters: list[str] | None = Query(
        default=None,

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Check the embedded error and proxy logs; verify the database connection, then retry.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/proxy/management_endpoints/user_agent_analytics_endpoints.py:207 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/c8799db97973245a. Report an issue: GitHub.