fix: don't create stub repos with TID as name, shorten issue rkey display ensure_repo_exists no longer creates garbage stub rows when the repo name is an unresolved TID. Issue cards show first 7 chars of rkey instead of the full TID.
Author: Aaron Steven White
Commit
894d126c8423533b42fbc532171afbfe0440e851Parent: 69bc21fbd8
Structural diff unavailable
These commits were pushed via plain git push, so no pre-parsed
schemas are available. Install git-remote-cospan and re-push via panproto:// to
see scope-level changes, breaking change detection, and semantic diffs.
brew install panproto/tap/git-remote-cospan2 files changed +30 -12
@@ -18,7 +18,7 @@
1818 <div class="min-w-0 flex-1"> 1919 <h3 class="font-semibold text-text-primary">{issue.title}</h3> 2020 <div class="mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-text-muted"> 21- <span>#{issue.rkey}</span> 21+ <span>#{issue.rkey.slice(0, 7)}</span> 2222 {#if issue.creatorHandle} 2323 <span>opened by {issue.creatorHandle}</span> 2424 {/if}
@@ -163,26 +163,44 @@ pub async fn resolve_rkey_to_name(
163163 Ok(row.map(|r| r.0).unwrap_or_else(|| rkey.to_string())) 164164 } 165165 166-/// Insert a stub repo row if one doesn't already exist for (did, name). 167-/// Used during backfill when child records (issues, pulls, etc.) arrive 168-/// before their parent repo. The stub will be overwritten with full data 169-/// when the repo record itself is processed. 166+/// Ensure a repo exists for (did, name) so FK constraints are satisfied. 167+/// If the name is already a real repo name, this is a no-op. 168+/// If the name is a TID/rkey (no real repo found yet), check if a repo 169+/// with this rkey exists and use its real name. Otherwise skip — the 170+/// child record will fail FK and be retried when the repo arrives. 170171 pub async fn ensure_exists( 171172 pool: &PgPool, 172173 did: &str, 173174 name: &str, 174- source: &str, 175+ _source: &str, 175176 ) -> Result<(), sqlx::Error> { 176- sqlx::query( 177- "INSERT INTO repos (did, rkey, name, protocol, node_did, node_url, source, created_at) \ 178- VALUES ($1, '', $2, 'git', '', '', $3, NOW()) \ 179- ON CONFLICT (did, name) DO NOTHING", 177+ // Check if repo already exists by name 178+ let exists: Option<(i64,)> = sqlx::query_as( 179+ "SELECT 1 FROM repos WHERE did = $1 AND name = $2", 180180 ) 181181 .bind(did) 182182 .bind(name) 183- .bind(source) 184- .execute(pool) 183+ .fetch_optional(pool) 185184 .await?; 185+ if exists.is_some() { 186+ return Ok(()); 187+ } 188+ // Check if it exists by rkey (name might be an unresolved rkey) 189+ let exists_by_rkey: Option<(i64,)> = sqlx::query_as( 190+ "SELECT 1 FROM repos WHERE did = $1 AND rkey = $2", 191+ ) 192+ .bind(did) 193+ .bind(name) 194+ .fetch_optional(pool) 195+ .await?; 196+ if exists_by_rkey.is_some() { 197+ // Repo exists under a different name — the caller should 198+ // resolve the rkey to the real name before inserting. 199+ return Ok(()); 200+ } 201+ // No repo found at all — don't create a stub with a TID as name, 202+ // it creates garbage data. Let the FK constraint fail; the record 203+ // will be retried when the repo arrives via backfill. 186204 Ok(()) 187205 } 188206