{"record":{"id":"c8799db97973245a","repo":"BerriAI/litellm","slug":"failed-to-fetch-distinct-user-agent-tags-e","errorCode":null,"errorMessage":"Failed to fetch distinct user agent tags: {e}","messagePattern":"Failed to fetch distinct user agent tags: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"litellm/proxy/management_endpoints/user_agent_analytics_endpoints.py","lineNumber":207,"sourceCode":"        sql_query: Final = f\"\"\"\n        SELECT \n            dts.tag,\n            COUNT(*) as usage_count\n        FROM \"LiteLLM_DailyTagSpend\" dts\n        WHERE dts.tag LIKE 'User-Agent:%' OR dts.tag NOT LIKE '%:%'\n        GROUP BY dts.tag\n        ORDER BY usage_count DESC\n        LIMIT {MAX_TAGS}\n        \"\"\"\n\n        db_response: Final = _DISTINCT_TAG_ROWS.validate_python(await _query_raw(prisma_client, sql_query))\n\n        results: Final = [DistinctTagResponse(tag=row.tag) for row in db_response]\n\n        return DistinctTagsResponse(results=results)\n\n    except Exception as e:\n        raise HTTPException(\n            status_code=500,\n            detail=f\"Failed to fetch distinct user agent tags: {e}\",\n        )\n\n\n@router.get(\n    \"/tag/dau\",\n    response_model=ActiveUsersAnalyticsResponse,\n    tags=[\"tag management\", \"user agent analytics\"],\n    dependencies=[Depends(user_api_key_auth)],\n)\nasync def get_daily_active_users(\n    tag_filter: str | None = Query(\n        default=None,\n        description=\"Filter by specific tag (optional)\",\n    ),\n    tag_filters: list[str] | None = Query(\n        default=None,","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/user_agent_analytics_endpoints.py#L189-L225","documentation":"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.","triggerScenarios":"Thrown at litellm/proxy/management_endpoints/user_agent_analytics_endpoints.py:207 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the embedded error and proxy logs; verify the database connection, then retry."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}