You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
profiles: enforce name uniqueness atomically in the user stores #343
Follow-up to #342, which enforces per-account profile name uniqueness at the API layer (handler compares against a ListProfiles snapshot before writing).
Gap
The check is read-then-write, so two concurrent creates/renames on the same account with the same trimmed, case-folded name can both pass the snapshot and both commit — neither the SQLite per-user store (internal/userdb) nor the Postgres store (internal/userstore/pgstore) constrains normalized names, only the profile-ID primary key. Raised by Codex review on #342 (P2).
Practical exposure is small (same household firing matching-name writes in the same instant), and the failure mode is the pre-#342 behavior: a duplicate name slips in. But the name_conflict contract should be a guarantee, not best-effort.
Proposed fix
Enforce in the store layer, both backends:
either a unique index on the normalized name (lower(trim(name)), per account in Postgres), or a check-then-insert inside the write transaction (SQLite: BEGIN IMMEDIATE);
a typed userstore.ErrProfileNameConflict the handler maps to the existing 409 name_conflict;
migration note: accounts holding pre-existing duplicates (created before fix(profiles): enforce per-account profile name uniqueness #342) will fail unique-index creation — needs a dedupe/rename migration first, or the transactional-check approach which grandfathers them.
I really like Django does this with it's slugify function. Eventually, I would like to replace the IDs in the URLs with slugs, where possible. For now, would it make sense to have it just for the uniqueness checks and a DB field? The actual plumbing into URLs can come later.
Activity
darthShadow commentedon Jul 8, 2026
I really like Django does this with it's slugify function. Eventually, I would like to replace the IDs in the URLs with slugs, where possible. For now, would it make sense to have it just for the uniqueness checks and a DB field? The actual plumbing into URLs can come later.
References: