{"record":{"id":"b5f7ace0b2b09b6c","repo":"paperclipai/paperclip","slug":"target-company-companyid-was-not-found","errorCode":null,"errorMessage":"Target company ${companyId} was not found.","messagePattern":"Target company (.+?) was not found\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/worktree.ts","lineNumber":3487,"sourceCode":"      .select()\n      .from(agents)\n      .where(eq(agents.companyId, companyId)),\n    input.targetDb\n      .select()\n      .from(projectWorkspaces)\n      .where(eq(projectWorkspaces.companyId, companyId)),\n    input.targetDb\n      .select()\n      .from(goals)\n      .where(eq(goals.companyId, companyId)),\n    input.sourceDb\n      .select({ count: sql<number>`count(*)::int` })\n      .from(heartbeatRuns)\n      .where(eq(heartbeatRuns.companyId, companyId)),\n  ]);\n\n  if (!targetCompanyRow) {\n    throw new Error(`Target company ${companyId} was not found.`);\n  }\n\n  const plan = buildWorktreeMergePlan({\n    companyId,\n    companyName: input.company.name,\n    issuePrefix: input.company.issuePrefix,\n    previewIssueCounterStart: targetCompanyRow.issueCounter,\n    scopes: input.scopes,\n    sourceIssues: sourceIssuesRows,\n    targetIssues: targetIssuesRows,\n    sourceComments: sourceCommentsRows,\n    targetComments: targetCommentsRows,\n    sourceProjects: sourceProjectsRows,\n    sourceProjectWorkspaces: sourceProjectWorkspaceRows,\n    sourceDocuments: sourceIssueDocumentsRows as IssueDocumentRow[],\n    targetDocuments: targetIssueDocumentsRows as IssueDocumentRow[],\n    sourceDocumentRevisions: sourceDocumentRevisionRows as DocumentRevisionRow[],\n    targetDocumentRevisions: targetDocumentRevisionRows as DocumentRevisionRow[],","sourceCodeStart":3469,"sourceCodeEnd":3505,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/cli/src/commands/worktree.ts#L3469-L3505","documentation":"Merge precondition failure: the company id chosen for the merge plan does not exist as a row in the target database, so target-side inserts would violate foreign keys; likely the target was seeded differently than expected.","triggerScenarios":"Thrown at cli/src/commands/worktree.ts:2672 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the company id exists in the target database and retry with a valid --company value."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}