{"record":{"id":"eb1853c8b803a278","repo":"paperclipai/paperclip","slug":"llm-wiki-space-not-found-slug","errorCode":null,"errorMessage":"LLM Wiki space not found: ${slug}","messagePattern":"LLM Wiki space not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/plugins/plugin-llm-wiki/src/wiki/core.ts","lineNumber":1370,"sourceCode":"  return rows[0] ? wikiSpaceFromRow(rows[0]) : fallbackDefaultSpace({ companyId: input.companyId, wikiId });\n}\n\nexport async function resolveSpace(ctx: PluginContext, input: SpaceInput): Promise<WikiSpace> {\n  const wikiId = normalizeWikiId(input.wikiId);\n  const slug = normalizeSpaceSlug(input.spaceSlug);\n  if (slug === DEFAULT_SPACE_SLUG) {\n    return ensureDefaultSpace(ctx, { companyId: input.companyId, wikiId });\n  }\n  const rows = await ctx.db.query<WikiSpaceRow>(\n    `SELECT id, company_id, wiki_id, slug, display_name, space_type, folder_mode, root_folder_key,\n            path_prefix, configured_root_path, access_scope, owner_user_id, owner_agent_id, team_key,\n            settings, status, created_at::text AS created_at, updated_at::text AS updated_at\n       FROM ${spaceTable(ctx)}\n      WHERE company_id = $1 AND wiki_id = $2 AND slug = $3 AND status <> 'archived'\n      LIMIT 1`,\n    [input.companyId, wikiId, slug],\n  );\n  if (!rows[0]) throw new Error(`LLM Wiki space not found: ${slug}`);\n  return wikiSpaceFromRow(rows[0]);\n}\n\nasync function resolveSpaceAnyStatus(ctx: PluginContext, input: SpaceInput): Promise<WikiSpace> {\n  const wikiId = normalizeWikiId(input.wikiId);\n  const slug = normalizeSpaceSlug(input.spaceSlug);\n  if (slug === DEFAULT_SPACE_SLUG) {\n    return ensureDefaultSpace(ctx, { companyId: input.companyId, wikiId });\n  }\n  const rows = await ctx.db.query<WikiSpaceRow>(\n    `SELECT id, company_id, wiki_id, slug, display_name, space_type, folder_mode, root_folder_key,\n            path_prefix, configured_root_path, access_scope, owner_user_id, owner_agent_id, team_key,\n            settings, status, created_at::text AS created_at, updated_at::text AS updated_at\n       FROM ${spaceTable(ctx)}\n      WHERE company_id = $1 AND wiki_id = $2 AND slug = $3\n      LIMIT 1`,\n    [input.companyId, wikiId, slug],\n  );","sourceCodeStart":1352,"sourceCodeEnd":1388,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/packages/plugins/plugin-llm-wiki/src/wiki/core.ts#L1352-L1388","documentation":"Thrown by resolveSpace when no wiki_spaces row matches the company/wiki/slug with status <> 'archived'. The default slug short-circuits to ensureDefaultSpace, so this only fires for non-default slugs that are missing or archived. Means the active space the caller referenced does not exist.","triggerScenarios":"Calling any space-scoped API (updatePaperclipIngestionProfile, resolveSpace, etc.) with a spaceSlug that was never created, was archived, or belongs to a different company/wiki.","commonSituations":"Referencing a slug before createSpace runs; operating on an archived space via the active-only resolver; typo in the slug; cross-company slug collision; stale UI link to a removed space.","solutions":["Verify the slug exists via listSpaces for the company before operating on it.","If the space is archived, restore it to 'active' via updateSpace first, or use the any-status resolver where appropriate.","Create the space with createSpace if it does not yet exist.","Confirm the companyId and wikiId match the space's owner."],"exampleFix":"// before\nawait resolveSpace(ctx, { companyId, spaceSlug: \"research\" }); // missing\n\n// after\nconst { spaces } = await listSpaces(ctx, { companyId });\nif (!spaces.some((s) => s.slug === \"research\")) {\n  await createSpace(ctx, { companyId, slug: \"research\", displayName: \"Research\" });\n}\nawait resolveSpace(ctx, { companyId, spaceSlug: \"research\" });","handlingStrategy":"validation","validationCode":"async function ensureActiveSpaceExists(ctx, companyId, slug) {\n  const { spaces } = await listSpaces(ctx, { companyId });\n  if (!spaces.some((s) => s.slug === slug)) {\n    throw new Error(`LLM Wiki space not found: ${slug}`);\n  }\n}","typeGuard":"function isActiveSpace(space) {\n  return !!space && space.status === \"active\" && !!space.slug;\n}","tryCatchPattern":"try {\n  await resolveSpace(ctx, { companyId, spaceSlug });\n} catch (err) {\n  if (/LLM Wiki space not found/.test(err.message)) {\n    await createSpace(ctx, { companyId, slug: spaceSlug, displayName: spaceSlug });\n    return resolveSpace(ctx, { companyId, spaceSlug });\n  }\n  throw err;\n}","preventionTips":["Validate slug against listSpaces before use.","Create the space first if missing.","Exclude archived spaces from active-space references."],"tags":["validation","wiki","spaces","not-found","paperclip"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}