Commita3b6378unknown_key
fix(admin): auto-merge check uses SELF_HOST_REPO, not hardcoded owner
fix(admin): auto-merge check uses SELF_HOST_REPO, not hardcoded owner
The /admin/health 'main protection' row was reporting 'Repository row
for ccantynz/Gluecron.com not found' on a deployment where the canonical
owner is actually ccantynz-alt (or wherever else the operator put it).
Resolution path:
1. Read SELF_HOST_REPO env var (canonical 'this is the platform repo' pointer)
2. Fall back to legacy default 'ccantynz/Gluecron.com' if unset
3. Surface the actual owner/repo being looked up in the error detail
so operators know what to fix
Both the 'owner not found' and 'repo not found' branches now include
actionable fix guidance:
- Owner not found → set SELF_HOST_REPO or register the user
- Repo not found → create the repo via /new or correct SELF_HOST_REPO
The branch_protection link in the 'no protection row' branch also now
points at the right owner/repo path instead of hardcoded /ccantynz/.
Tests: 3/3 admin-health pass. tsc clean.1 file changed+17−5a3b6378f36d2c469de1a30f3609e8d301e81a507
1 changed file+17−5
Modifiedsrc/routes/admin-diagnose.tsx+17−5View fileUnifiedSplit
@@ -287,18 +287,29 @@ async function checkMigrations(): Promise<CheckResult> {
287287}
288288
289289async function checkAutoMerge(): Promise<CheckResult> {
290 // Resolve which repo to check. SELF_HOST_REPO is the canonical
291 // "this is the platform's own repo" pointer — falling back to
292 // `ccantynz/Gluecron.com` keeps the legacy default behaviour.
293 // Without this, the check used to hardcode `ccantynz` and report
294 // "Owner not found" for installs where the canonical owner is
295 // `ccantynz-alt` or anything else.
296 const selfRepo = process.env.SELF_HOST_REPO || "ccantynz/Gluecron.com";
297 const [ownerName, repoName] = selfRepo.includes("/")
298 ? selfRepo.split("/")
299 : [selfRepo, "Gluecron.com"];
290300 try {
291301 const [owner] = await db
292302 .select({ id: users.id })
293303 .from(users)
294 .where(eq(users.username, "ccantynz"))
304 .where(eq(users.username, ownerName))
295305 .limit(1);
296306 if (!owner) {
297307 return {
298308 category: "Auto-merge",
299309 name: "main protection",
300310 status: "yellow",
301 detail: "Owner user 'ccantynz' not found.",
311 detail: `Owner user '${ownerName}' not found in users table (looked up via SELF_HOST_REPO).`,
312 fix: "Set SELF_HOST_REPO=<actual-owner>/<repo> in /etc/gluecron.env, or register the owner.",
302313 };
303314 }
304315 const [repo] = await db
@@ -307,7 +318,7 @@ async function checkAutoMerge(): Promise<CheckResult> {
307318 .where(
308319 and(
309320 eq(repositories.ownerId, owner.id),
310 eq(repositories.name, "Gluecron.com")
321 eq(repositories.name, repoName)
311322 )
312323 )
313324 .limit(1);
@@ -316,7 +327,8 @@ async function checkAutoMerge(): Promise<CheckResult> {
316327 category: "Auto-merge",
317328 name: "main protection",
318329 status: "yellow",
319 detail: "Repository row for ccantynz/Gluecron.com not found.",
330 detail: `Repository row for ${ownerName}/${repoName} not found. Either the platform repo isn't registered in its own DB, or SELF_HOST_REPO points at the wrong owner/name.`,
331 fix: `Create the repo at /new (owner=${ownerName}, name=${repoName}), or correct SELF_HOST_REPO in /etc/gluecron.env.`,
320332 };
321333 }
322334 const [bp] = await db
@@ -335,7 +347,7 @@ async function checkAutoMerge(): Promise<CheckResult> {
335347 name: "main protection",
336348 status: "yellow",
337349 detail: "No branch_protection row for main yet.",
338 fix: "Visit /ccantynz/Gluecron.com/gates/protection to configure.",
350 fix: `Visit /${ownerName}/${repoName}/gates/protection to configure.`,
339351 };
340352 }
341353 return {
342354