{"record":{"id":"bae3bc00ea2280a0","repo":"paperclipai/paperclip","slug":"selected-llm-wiki-project-was-not-found","errorCode":null,"errorMessage":"Selected LLM Wiki project was not found.","messagePattern":"Selected LLM Wiki project was not found\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/plugins/plugin-llm-wiki/src/wiki/core.ts","lineNumber":2145,"sourceCode":"    reconcileWikiAgentResource(ctx, companyId),\n    reconcileWikiProjectResource(ctx, companyId),\n  ]);\n\n  const managedRoutines = await Promise.all(\n    WIKI_MAINTENANCE_ROUTINE_KEYS.map((routineKey) =>\n      ctx.routines.managed.reconcile(routineKey, companyId, {\n        assigneeAgentId: managedAgent.agentId,\n        projectId: managedProject.projectId,\n      })),\n  );\n\n  return { managedAgent, managedProject, managedRoutines };\n}\n\nexport async function selectWikiProjectResource(ctx: PluginContext, input: { companyId: string; projectId: string }): Promise<WikiProjectResource> {\n  const project = await ctx.projects.get(input.projectId, input.companyId);\n  if (!project) {\n    throw new Error(\"Selected LLM Wiki project was not found.\");\n  }\n  await upsertResourceBinding(ctx, {\n    companyId: input.companyId,\n    wikiId: DEFAULT_WIKI_ID,\n    resourceKind: \"project\",\n    resourceKey: WIKI_PROJECT_KEY,\n    resolvedId: project.id,\n    metadata: { source: \"selected-existing\", updatedBy: \"settings\" },\n  });\n  return projectResource({ status: \"resolved\", source: \"selected\", project });\n}\n\nexport async function listWikiAgentOptions(ctx: PluginContext, companyId: string): Promise<WikiResourceOption[]> {\n  const agents = await ctx.agents.list({ companyId, limit: 200 });\n  return agents\n    .filter((agent) => agent.status !== \"terminated\")\n    .map((agent) => ({\n      id: agent.id,","sourceCodeStart":2127,"sourceCodeEnd":2163,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/packages/plugins/plugin-llm-wiki/src/wiki/core.ts#L2127-L2163","documentation":"Thrown by selectWikiProjectResource when ctx.projects.get(projectId, companyId) returns nullish. The lookup is company-scoped, so null means the project is missing, deleted, or belongs to a different company. The Wiki project binding must reference a project in the same company.","triggerScenarios":"Calling selectWikiProjectResource with a projectId that does not exist, was deleted, or is owned by another company.","commonSituations":"Stale project id in a dropdown after deletion; cross-company project reference; test fixture pointing at a removed project; race between project creation and selection.","solutions":["List project options via listWikiProjectOptions (or ctx.projects.list) and select an existing one for the company.","Fall back to resetWikiProjectResource to bind the managed default project.","Confirm the companyId owns the projectId before submitting.","If the project was just created, ensure it is readable before binding."],"exampleFix":"// before\nawait selectWikiProjectResource(ctx, { companyId, projectId: pickedProjectId });\n\n// after\nconst opts = await listWikiProjectOptions(ctx, companyId);\nconst live = opts.find((p) => p.id === pickedProjectId);\nif (!live) {\n  return selectWikiProjectResource(await resetWikiProjectResource(ctx, companyId));\n}\nawait selectWikiProjectResource(ctx, { companyId, projectId: live.id });","handlingStrategy":"validation","validationCode":"async function ensureSelectableProject(ctx, companyId, projectId) {\n  const opts = await listWikiProjectOptions(ctx, companyId);\n  if (!opts.some((p) => p.id === projectId)) {\n    throw new Error(\"Selected LLM Wiki project was not found.\");\n  }\n}","typeGuard":"function isExistingProject(project) {\n  return !!project && typeof project.id === \"string\";\n}","tryCatchPattern":"try {\n  await selectWikiProjectResource(ctx, { companyId, projectId });\n} catch (err) {\n  if (/Selected LLM Wiki project was not found/.test(err.message)) {\n    return resetWikiProjectResource(ctx, companyId);\n  }\n  throw err;\n}","preventionTips":["Source project options from listWikiProjectOptions.","Confirm company ownership before binding.","Fall back to the managed default via resetWikiProjectResource."],"tags":["validation","wiki","projects","company-scope","paperclip"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}