mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[GH-ISSUE #21737] issue: Tag duplicate-key errors: unique index on tag(id) conflicts with PK(id, user_id) #19556
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @martional on GitHub (Feb 22, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/21737
Check Existing Issues
Installation Method
Docker
Open WebUI Version
v0.8.3
Ollama Version (if applicable)
N/A
Operating System
Ubuntu 22.04
Browser (if applicable)
Chrome 120
Confirmation
README.md.Expected Behavior
Expected Behavior
Tags should be uniquely identified by the composite key
(id, user_id). Multiple users can have tags with the sameid(e.g. both User A and User B can have a tag named "work"). No unique constraint should exist onidalone. Tag creation and updates should succeed without duplicate-key errors.Actual Behavior
Actual Behavior
Duplicate-key errors occur when inserting or updating tags. The database rejects the operation because a unique index on
tag.idalone conflicts with the intended composite primary key(id, user_id).Typical errors:
UNIQUE constraint failed: tag.idduplicate key value violates unique constraintThis happens when two different users create a tag with the same name, or when tag operations trigger inserts that conflict with the leftover unique index on
id.Steps to Reproduce
Steps to Reproduce
docker run -d -p 8080:8080 --name open-webui ghcr.io/open-webui/open-webui:main).Alternative:
tag.idfrom the original schema.Prerequisites: Database must have been created or migrated from a version where the tag table had
PK(id)and the migration toPK(id, user_id)did not fully remove the unique index onidalone.Logs & Screenshots
Logs & Screenshots
Docker logs:
Example error (SQLite):
Example error (PostgreSQL):
Database check (optional):
If you see a unique index on
idalone (e.g.sqlite_autoindex_tag_1or similar), that confirms the issue.Additional Information
Additional Information
Root cause: The
tagtable was originally created withPrimaryKeyConstraint("id")in the init migration. Migration1af9b942657baddeduser_idand createduq_id_user_idon(id, user_id). Migration3ab32c4b8f59changed the PK to(id, user_id)and attempted to drop conflicting constraints. In some upgrade paths or database engines (e.g. SQLite autoindexes, or different upgrade orders), a unique index onidalone can persist and cause the errors described above.Proposed fix: A follow-up migration that explicitly drops any unique index on
tag.idalone (if it exists) would resolve the issue for affected installations.@tjbck commented on GitHub (Feb 22, 2026):
Unable to reproduce, we never had unique id constraint afaik.