HKUDS/DeepTutor · error · HTTPException
Tag already exists
Error message
Tag already exists: {exc} What it means
Route-level translation of TagExistsError from the skill service: a tag with the same (normalized) name already exists, so creation is refused with 409 and the service's detail naming the conflicting tag.
Solutions
- List existing tags first and reuse the existing one
- Client: on 409, fetch the tag list and link to the existing tag instead of creating
- Normalize (trim/case-fold) the requested name before submitting to avoid near-duplicate clashes
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at deeptutor/api/routers/skills.py:89 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27).
Data as JSON: /api/errors/904c1f4c13cab5ce.
Report an issue: GitHub.
Appendix: source
Thrown at deeptutor/api/routers/skills.py:89
rename_to: str = Field(..., min_length=1, max_length=32)
# ── tag routes (declared before `/{name}` so they are not shadowed) ──
@router.get("/tags/list")
async def list_tags() -> dict[str, list[str]]:
service = get_skill_service()
return {"tags": service.list_tags()}
@router.post("/tags/create")
async def create_tag(payload: CreateTagRequest) -> dict[str, str]:
service = get_skill_service()
try:
tag = service.create_tag(payload.name)
except TagExistsError as exc:
raise HTTPException(status_code=409, detail=f"Tag already exists: {exc}")
except InvalidTagError as exc:
raise HTTPException(status_code=400, detail=str(exc))
return {"name": tag}
@router.put("/tags/{tag}")
async def rename_tag(tag: str, payload: RenameTagRequest) -> dict[str, str]:
service = get_skill_service()
try:
new_tag = service.rename_tag(tag, payload.rename_to)
except TagNotFoundError:
raise HTTPException(status_code=404, detail=f"Tag not found: {tag}")
except TagExistsError as exc:
raise HTTPException(status_code=409, detail=f"Tag already exists: {exc}")
except InvalidTagError as exc:
raise HTTPException(status_code=400, detail=str(exc))
return {"name": new_tag}
View on GitHub (pinned to 3e82f13042)