Claim the bot's name only when it is free !135

merged merged by cmc on 2026-08-31 16:33 UTC · krz/gitbay:bot-name-guard into main

Discussion

cmc

Closes #64.

Migration 0028 inserted gitbay-bot unconditionally. The name was not reserved before that migration, so an instance upgrading from v1.0.x may already have a user holding it — the insert hits the UNIQUE constraint on users.username, the migration aborts, and the daemon does not start. An org of the same name is the quieter version: the insert succeeds and the instance ends up with a user and an org sharing one owner name.

Editing 0028 rather than adding 0029, because 0028 is unreleased (v1.0.1 predates it) and a later migration cannot rescue an earlier one that aborts. Migrations are tracked by version number with no content hash, so this instance — which has already applied 0028 — does not re-run it and keeps the account it created.

The tests fail without the fix, with the real symptom:

migration 0028 failed with user "gitbay-bot" present:
UNIQUE constraint failed: users.username (2067)

When the account is absent the worker now names the cause, and it surfaces in repo deps status as the check's last error rather than as a stuck feature with no explanation.