{"record":{"id":"70c285e8cf60b902","repo":"paperclipai/paperclip","slug":"issue-belongs-to-another-company-or-does-not-exist","errorCode":null,"errorMessage":"Issue belongs to another company or does not exist: ${issueId}","messagePattern":"Issue belongs to another company or does not exist: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/plugins/plugin-llm-wiki/src/wiki/core.ts","lineNumber":1016,"sourceCode":"    if (scope.kind === \"company_all\" && input.space.slug !== DEFAULT_SPACE_SLUG) {\n      throw new Error(\"Everything in the company is only available on the default wiki space.\");\n    }\n    if (scope.kind === \"selected_projects\") {\n      if (scope.projectIds.length > MAX_PAPERCLIP_PROFILE_SELECTED_PROJECTS) {\n        throw new Error(`selected_projects exceeds the hard cap of ${MAX_PAPERCLIP_PROFILE_SELECTED_PROJECTS}.`);\n      }\n      for (const projectId of scope.projectIds) {\n        const project = await ctx.projects.get(projectId, input.companyId);\n        if (!project) throw new Error(`Project belongs to another company or does not exist: ${projectId}`);\n      }\n    }\n    if (scope.kind === \"root_issues\") {\n      if (scope.issueIds.length > MAX_PAPERCLIP_PROFILE_ROOT_ISSUES) {\n        throw new Error(`root_issues exceeds the hard cap of ${MAX_PAPERCLIP_PROFILE_ROOT_ISSUES}.`);\n      }\n      for (const issueId of scope.issueIds) {\n        const issue = await ctx.issues.get(issueId, input.companyId);\n        if (!issue) throw new Error(`Issue belongs to another company or does not exist: ${issueId}`);\n      }\n    }\n  }\n}\n\nexport async function updatePaperclipIngestionProfile(ctx: PluginContext, input: {\n  companyId: string;\n  wikiId?: string | null;\n  spaceSlug?: string | null;\n  profile: unknown;\n}): Promise<PaperclipIngestionProfileRead> {\n  const wikiId = normalizeWikiId(input.wikiId);\n  const space = await resolveSpace(ctx, { companyId: input.companyId, wikiId, spaceSlug: input.spaceSlug });\n  const current = await profileForSpace(ctx, input.companyId, space);\n  const profile = normalizePaperclipIngestionProfile(input.profile, { space, legacySettings: space.slug === DEFAULT_SPACE_SLUG ? await getEventIngestionSettings(ctx, input.companyId) : null });\n  await validatePaperclipIngestionProfile(ctx, { companyId: input.companyId, space, profile });\n  await updateSpace(ctx, {\n    companyId: input.companyId,","sourceCodeStart":998,"sourceCodeEnd":1034,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/packages/plugins/plugin-llm-wiki/src/wiki/core.ts#L998-L1034","documentation":"Thrown during profile validation when ctx.issues.get(issueId, companyId) returns nullish for an id in a 'root_issues' scope. The lookup is company-scoped, so null means the issue is missing, deleted, belongs to another company, or is not a root issue retrievable by id. Protects ingestion from cross-company or stale references.","triggerScenarios":"Submitting a 'root_issues' scope containing a deleted, mistyped, cross-company, or non-existent issue id through updatePaperclipIngestionProfile.","commonSituations":"Stale id from a previously deleted issue; ids copied from another tenant; transient state right after issue creation; non-root issue id used where root issues are expected.","solutions":["Call listPaperclipIngestionCandidates and only keep rootIssues ids it returns for the current company.","Drop invalid ids before submission or prompt the user to re-pick.","Confirm the companyId in the request owns every issueId.","If issues were just created, ensure they are readable before referencing them."],"exampleFix":"// before\nprofile.sourceScopes = [{ kind: \"root_issues\", issueIds: rawIssueIds }];\n\n// after\nconst candidates = await listPaperclipIngestionCandidates(ctx, { companyId, wikiId });\nconst valid = new Set(candidates.rootIssues.map((i) => i.id));\nprofile.sourceScopes = [{\n  kind: \"root_issues\",\n  issueIds: rawIssueIds.filter((id) => valid.has(id)),\n}];","handlingStrategy":"validation","validationCode":"async function filterExistingRootIssues(ctx, companyId, issueIds) {\n  const candidates = await listPaperclipIngestionCandidates(ctx, { companyId, wikiId: DEFAULT_WIKI_ID });\n  const valid = new Set(candidates.rootIssues.map((i) => i.id));\n  return issueIds.filter((id) => valid.has(id));\n}","typeGuard":"function isLikelyIssueId(id) {\n  return typeof id === \"string\" && id.length > 0 && /^[a-zA-Z0-9_-]+$/.test(id);\n}","tryCatchPattern":"try {\n  await updatePaperclipIngestionProfile(ctx, { companyId, spaceSlug, profile });\n} catch (err) {\n  if (/Issue belongs to another company or does not exist/.test(err.message)) {\n    const id = err.message.split(\": \").pop();\n    profile.sourceScopes = profile.sourceScopes.map((s) =>\n      s.kind === \"root_issues\" ? { ...s, issueIds: s.issueIds.filter((p) => p !== id) } : s);\n    return updatePaperclipIngestionProfile(ctx, { companyId, spaceSlug, profile });\n  }\n  throw err;\n}","preventionTips":["Use the candidate list to populate root-issue pickers.","Confirm company ownership of every id.","Avoid caching issue ids across long sessions."],"tags":["validation","ingestion","wiki","company-scope","paperclip"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}