{"record":{"id":"f5224af53a8808da","repo":"paperclipai/paperclip","slug":"no-representative-cloned-company-and-issue-pair-is","errorCode":null,"errorMessage":"No representative cloned company and issue pair is readable.","messagePattern":"No representative cloned company and issue pair is readable\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/worktree.ts","lineNumber":1642,"sourceCode":"          : \"No auth user has an instance-admin role and active company membership for local-trusted worktree seeding.\",\n      );\n    }\n\n    const representative = await db\n      .select({ companyId: companies.id, issueId: issues.id })\n      .from(companies)\n      .innerJoin(issues, eq(issues.companyId, companies.id))\n      .where(\n        and(\n          expected ? eq(companies.id, expected.representativeCompanyId) : undefined,\n          expected ? eq(issues.id, expected.representativeIssueId) : undefined,\n          requiredCompanyId ? eq(companies.id, requiredCompanyId) : undefined,\n        ),\n      )\n      .limit(1)\n      .then((rows) => rows[0] ?? null);\n    if (!representative) {\n      throw new Error(\"No representative cloned company and issue pair is readable.\");\n    }\n\n    const summary: WorktreeSeedValidationSummary = {\n      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","sourceCodeStart":1624,"sourceCodeEnd":1660,"githubUrl":"https://github.com/paperclipai/paperclip/blob/a7e689b3c35347b529cb9f54c9b9a8575a3dcab6/cli/src/commands/worktree.ts#L1624-L1660","documentation":"After the admin check, seed validation selects one representative row from companies INNER JOIN issues (with optional expected representative ids and required company filters). The inner join means a company with zero issues produces no row. This pair is the proof that cloned business data is readable, and its ids are recorded in the seed expectation.","triggerScenarios":"The representative query runs when the source DB has no company that owns at least one issue, or when expected.representativeCompanyId / representativeIssueId / requiredCompanyId filters exclude every existing pair (e.g. the recorded issue was deleted since the expectation was written).","commonSituations":"A freshly onboarded instance with a company but no issues yet; issues deleted after the seed expectation was recorded; wrong PAPERCLIP_SEED_EXPECTED_COMPANY_ID pinning a company that has no issues.","solutions":["Create at least one issue in the source company so a company-issue pair exists, then retry","If the expectation is stale (deleted issue/company), clear the seed expectation or markers so it is re-derived","Check requiredCompanyId / expected ids passed via options or env actually match live rows"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"-- pre-check: a representative pair must exist\nSELECT c.id AS company_id, i.id AS issue_id\nFROM companies c\nJOIN issues i ON i.company_id = c.id\nLIMIT 1; -- zero rows = seed will fail","typeGuard":null,"tryCatchPattern":"Catch and report 'source has no company with an issue; create one issue before seeding' rather than retrying blindly.","preventionTips":["Seed from instances that already have real content (at least one company with one issue)","When pinning expected representative ids, refresh them after deleting issues or companies"],"tags":["worktree","seed","database","data-integrity"],"backgroundTag":"empty-seed-data","analyzedSha":"a7e689b3c35347b529cb9f54c9b9a8575a3dcab6","analyzedAt":"2026-08-21T17:58:32.592Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}