{"record":{"id":"cf88f20f1161edf4","repo":"BerriAI/litellm","slug":"tag-tag-name-already-exists","errorCode":null,"errorMessage":"Tag {tag.name} already exists","messagePattern":"Tag (.+?) already exists","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/management_endpoints/tag_management_endpoints.py","lineNumber":288,"sourceCode":"    - model_max_budget: Optional[dict] - Max budget for a specific model\n    - budget_duration: Optional[str] - Frequency of resetting tag budget\n    \"\"\"\n    from litellm.proxy._types import CommonProxyErrors\n    from litellm.proxy.proxy_server import (\n        litellm_proxy_admin_name,\n        llm_router,\n        prisma_client,\n    )\n\n    if prisma_client is None:\n        raise HTTPException(status_code=500, detail=CommonProxyErrors.db_not_connected_error.value)\n    if llm_router is None:\n        raise HTTPException(status_code=500, detail=CommonProxyErrors.no_llm_router.value)\n    try:\n        # Check if tag already exists\n        existing_tag: Final = await _table(TagRepository(prisma_client)).find_unique(where={\"tag_name\": tag.name})\n        if existing_tag is not None:\n            raise HTTPException(status_code=400, detail=f\"Tag {tag.name} already exists\")\n\n        # Handle budget creation/assignment using common helper\n        budget_id: Final = await handle_budget_for_entity(\n            data=tag,\n            existing_budget_id=None,\n            user_api_key_dict=user_api_key_dict,\n            prisma_client=prisma_client,\n            litellm_proxy_admin_name=litellm_proxy_admin_name,\n        )\n\n        # Get model names for model_info\n        model_info: Final = await _get_model_names(prisma_client, tag.models or [])\n\n        # Create new tag in database\n        new_tag_record: Final = await _table(TagRepository(prisma_client)).create(\n            data={\n                \"tag_name\": tag.name,\n                \"description\": tag.description,","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/tag_management_endpoints.py#L270-L306","documentation":"POST /tag/new found an existing LiteLLM_BudgetTable/tag record with the same tag_name: tags are unique by name, so the create is refused with 400 to prevent overwriting an existing tag's budget configuration.","triggerScenarios":"Thrown at litellm/proxy/management_endpoints/tag_management_endpoints.py:288 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a different tag name, or update the existing tag."],"exampleFix":null,"handlingStrategy":"validation","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-14T05:17:10.506Z"}