{"record":{"id":"25078d226e82bc29","repo":"paperclipai/paperclip","slug":"seed-validation-found-an-incomplete-auth-membersh","errorCode":null,"errorMessage":"Seed validation found an incomplete auth, membership, company, or issue shape.","messagePattern":"Seed validation found an incomplete auth, membership, company, or issue shape\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/worktree.ts","lineNumber":1664,"sourceCode":"      authUserCount: counts?.authUserCount ?? 0,\n      credentialAccountCount: counts?.credentialAccountCount ?? 0,\n      instanceAdminCount: counts?.instanceAdminCount ?? 0,\n      activeMembershipCount: counts?.activeMembershipCount ?? 0,\n      companyCount: counts?.companyCount ?? 0,\n      issueCount: counts?.issueCount ?? 0,\n      representativeCompanyId: representative.companyId,\n      representativeIssueId: representative.issueId,\n      migrationRevision,\n    };\n    if (\n      summary.authUserCount < 1\n      || (requiresCredentialAccount && summary.credentialAccountCount < 1)\n      || summary.instanceAdminCount < 1\n      || summary.activeMembershipCount < 1\n      || summary.companyCount < 1\n      || summary.issueCount < 1\n    ) {\n      throw new Error(\"Seed validation found an incomplete auth, membership, company, or issue shape.\");\n    }\n\n    return {\n      summary,\n      expectation: {\n        adminUserId: admin.userId,\n        representativeCompanyId: representative.companyId,\n        representativeIssueId: representative.issueId,\n      },\n    };\n  } finally {\n    await db.$client?.end?.({ timeout: 5 }).catch(() => undefined);\n  }\n}\n\nasync function seedWorktreeDatabase(input: {\n  sourceConfigPath: string;\n  sourceConfig: PaperclipConfig;","sourceCodeStart":1646,"sourceCodeEnd":1682,"githubUrl":"https://github.com/paperclipai/paperclip/blob/a7e689b3c35347b529cb9f54c9b9a8575a3dcab6/cli/src/commands/worktree.ts#L1646-L1682","documentation":"A belt-and-braces count check after the row-level admin and representative probes: the validation summary must show at least one auth user, one instance admin, one active membership, one company, one issue — and one credential account when the mode requires it. It catches partially-populated databases that slip past the point checks because the queries used different filters.","triggerScenarios":"Any of the summary counts (authUserCount, credentialAccountCount when requiresCredentialAccount, instanceAdminCount, activeMembershipCount, companyCount, issueCount) is zero — typically a partial clone/restore where one table lost all rows while others kept theirs.","commonSituations":"A snapshot restored with one table missing; pg_restore interrupted; a hand-built source database with users but no memberships; concurrent truncation between the count query and the row queries.","solutions":["Re-snapshot or re-clone from a healthy source database and reseed the target","Verify the source DB passes all counts itself before using it as a seed origin","If a specific table is empty on the source, fix the source data (onboard/create records) and retry"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const counts = await countSeedShape(/* source connection */);\nconst ok = counts.authUserCount >= 1 && counts.instanceAdminCount >= 1\n  && counts.activeMembershipCount >= 1 && counts.companyCount >= 1 && counts.issueCount >= 1\n  && (!requiresCredentialAccount || counts.credentialAccountCount >= 1);\nif (!ok) throw new Error('Source DB is not a viable seed origin; fix or re-snapshot it.');","typeGuard":null,"tryCatchPattern":"Catch and fall back to re-snapshotting from a known-healthy source instead of seeding from the partial database.","preventionTips":["Verify seed-origin counts before cloning, not after","Prevent partial restores: validate pg_dump/pg_restore exit codes on the snapshot pipeline"],"tags":["worktree","seed","database","data-integrity","validation"],"backgroundTag":"incomplete-seed-data","analyzedSha":"a7e689b3c35347b529cb9f54c9b9a8575a3dcab6","analyzedAt":"2026-08-21T17:58:32.592Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}