{"record":{"id":"2a87b749f14e9f76","repo":"stablyai/orca","slug":"linked-work-item-and-source-context-identities-mus","errorCode":null,"errorMessage":"Linked work item and source context identities must match","messagePattern":"Linked work item and source context identities must match","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/ipc/worktrees.ts","lineNumber":277,"sourceCode":"  T extends {\n    linkedWorkItem?: unknown\n    linkedTaskSourceContext?: unknown\n  }\n>(input: T): T {\n  const linkedWorkItem =\n    input.linkedWorkItem === undefined\n      ? undefined\n      : NullableWorkspaceLinkedItemSchema.parse(input.linkedWorkItem)\n  const linkedTaskSourceContext =\n    input.linkedTaskSourceContext === undefined\n      ? undefined\n      : NullableTaskSourceContextSchema.parse(input.linkedTaskSourceContext)\n  if (\n    linkedWorkItem &&\n    linkedTaskSourceContext &&\n    !isWorkspaceLinkedItemSourceContextMatch(linkedWorkItem, linkedTaskSourceContext)\n  ) {\n    throw new Error('Linked work item and source context identities must match')\n  }\n  return {\n    ...input,\n    ...(linkedWorkItem !== undefined ? { linkedWorkItem } : {}),\n    ...(linkedTaskSourceContext !== undefined ? { linkedTaskSourceContext } : {})\n  }\n}\n\nasync function mapWithConcurrency<T, R>(\n  items: readonly T[],\n  limit: number,\n  fn: (item: T) => Promise<R>\n): Promise<R[]> {\n  const results: R[] = []\n  let nextIndex = 0\n  const workerCount = Math.min(limit, items.length)\n  await Promise.all(\n    Array.from({ length: workerCount }, async () => {","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/worktrees.ts#L259-L295","documentation":"Thrown by normalizeLinkedWorkItemFields while preprocessing every worktrees:create (and similar) IPC payload. After Zod-parsing both fields, it asserts that a present linkedWorkItem and a present linkedTaskSourceContext refer to the same task source via isWorkspaceLinkedItemSourceContextMatch (provider equality, plus for Jira a full site/project/issue-key match). It rejects mixed-provider or identity-divergent pairs before any Git work runs.","triggerScenarios":"A worktrees:create IPC call supplies linkedWorkItem and linkedTaskSourceContext together but they disagree — e.g. a GitHub issue item paired with a Jira source context, or a Jira item whose jiraIdentifier/url site differs from the context's providerIdentity (siteId/siteUrl/projectKey).","commonSituations":"Renderer state gets out of sync when a user switches task provider mid-form, when a Jira issue URL is pasted from a different site than the configured Jira connection, or when two different task seeds are merged into one create request.","solutions":["Send linkedWorkItem and linkedTaskSourceContext that originate from the same task source, or omit one of them.","For Jira, verify the item's jiraIdentifier and URL site match the context's providerIdentity.siteUrl and projectKey before submitting.","Re-derive linkedTaskSourceContext from the selected linkedWorkItem in the renderer (e.g. via the same useComposerState matching helper) so they cannot drift."],"exampleFix":"// before\ninvoke('worktrees:create', { repoId, linkedWorkItem: ghIssue, linkedTaskSourceContext: jiraContext })\n// after\ninvoke('worktrees:create', { repoId, linkedWorkItem: ghIssue, linkedTaskSourceContext: ghContext })","handlingStrategy":"validation","validationCode":"// Before invoking worktrees:create, ensure identity match client-side.\nimport { isWorkspaceLinkedItemSourceContextMatch } from '../../shared/workspace-linked-item-source-context'\n\nfunction safeCreateArgs(args) {\n  const { linkedWorkItem, linkedTaskSourceContext } = args\n  if (\n    linkedWorkItem &&\n    linkedTaskSourceContext &&\n    !isWorkspaceLinkedItemSourceContextMatch(linkedWorkItem, linkedTaskSourceContext)\n  ) {\n    throw new Error('linkedWorkItem and linkedTaskSourceContext disagree; fix before create')\n  }\n  return args\n}","typeGuard":"function isLinkedItemContextPairConsistent(\n  item: unknown,\n  ctx: unknown\n): boolean {\n  if (!item || !ctx) return true // absent on either side is allowed\n  return isWorkspaceLinkedItemSourceContextMatch(\n    item as Parameters<typeof isWorkspaceLinkedItemSourceContextMatch>[0],\n    ctx as Parameters<typeof isWorkspaceLinkedItemSourceContextMatch>[1]\n  )\n}","tryCatchPattern":null,"preventionTips":["Derive linkedTaskSourceContext from the selected linkedWorkItem in the renderer so they cannot drift.","Re-run the match check in the renderer before enabling the create action.","For Jira, validate the issue URL site and project key against the configured Jira connection identity."],"tags":["validation","ipc","worktree-create","task-linking"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}