~bigbes/sr-ht-dolt: 74d2612e

fix(db): map repository_path_key to ErrNameTaken

CreateRepo only recognized uq_repo_owner_id_name as a name collision, but
path is derived from (owner, name) by RepoDiskPath, so a duplicate always
violates both indexes -- and repository_path_key, declared inline on the
column, has the lower OID and is the one Postgres reports. ErrNameTaken was
therefore unreachable in practice and every duplicate surfaced as a raw
23505, breaking all three callers that branch on it:

  - /internal/repos returned 500 "create database" instead of an idempotent
    200, so git.sr.ht's post-update hook printed "companion provisioning
    failed (500)" on every push to a repo whose companion already existed
  - the web create form returned 500 instead of 409 "You already have a
    database with that name."
  - a lost remotesapi auto-create race failed with codes.Unavailable
    instead of adopting the winner's row

TestCreateRepoDuplicateName missed it by re-creating under a different
path, which only the name index catches; it is now table-driven over both.

Eugene Blikh <bigbes@gmail.com> — 2026-07-24 17:48:25 UTC

Commit 74d2612eac643b9e6e038e6dd1a3dda9b7940519view raw patch

Parent(s): 8e89f8a0

3 changed file(s)

FileStatus+
db/repos.go M +14 -4
db/repos_test.go M +27 -11
db/store.go M +2 -1