paperclipai/paperclip · error · Error

LLM Wiki space not found: ${slug}

Error message

LLM Wiki space not found: ${slug}

What it means

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.

Source

Thrown at packages/plugins/plugin-llm-wiki/src/wiki/core.ts:1370

  return rows[0] ? wikiSpaceFromRow(rows[0]) : fallbackDefaultSpace({ companyId: input.companyId, wikiId });
}

export async function resolveSpace(ctx: PluginContext, input: SpaceInput): Promise<WikiSpace> {
  const wikiId = normalizeWikiId(input.wikiId);
  const slug = normalizeSpaceSlug(input.spaceSlug);
  if (slug === DEFAULT_SPACE_SLUG) {
    return ensureDefaultSpace(ctx, { companyId: input.companyId, wikiId });
  }
  const rows = await ctx.db.query<WikiSpaceRow>(
    `SELECT id, company_id, wiki_id, slug, display_name, space_type, folder_mode, root_folder_key,
            path_prefix, configured_root_path, access_scope, owner_user_id, owner_agent_id, team_key,
            settings, status, created_at::text AS created_at, updated_at::text AS updated_at
       FROM ${spaceTable(ctx)}
      WHERE company_id = $1 AND wiki_id = $2 AND slug = $3 AND status <> 'archived'
      LIMIT 1`,
    [input.companyId, wikiId, slug],
  );
  if (!rows[0]) throw new Error(`LLM Wiki space not found: ${slug}`);
  return wikiSpaceFromRow(rows[0]);
}

async function resolveSpaceAnyStatus(ctx: PluginContext, input: SpaceInput): Promise<WikiSpace> {
  const wikiId = normalizeWikiId(input.wikiId);
  const slug = normalizeSpaceSlug(input.spaceSlug);
  if (slug === DEFAULT_SPACE_SLUG) {
    return ensureDefaultSpace(ctx, { companyId: input.companyId, wikiId });
  }
  const rows = await ctx.db.query<WikiSpaceRow>(
    `SELECT id, company_id, wiki_id, slug, display_name, space_type, folder_mode, root_folder_key,
            path_prefix, configured_root_path, access_scope, owner_user_id, owner_agent_id, team_key,
            settings, status, created_at::text AS created_at, updated_at::text AS updated_at
       FROM ${spaceTable(ctx)}
      WHERE company_id = $1 AND wiki_id = $2 AND slug = $3
      LIMIT 1`,
    [input.companyId, wikiId, slug],
  );

View on GitHub (pinned to 67001ec6eb)

Solutions

  1. Verify the slug exists via listSpaces for the company before operating on it.
  2. If the space is archived, restore it to 'active' via updateSpace first, or use the any-status resolver where appropriate.
  3. Create the space with createSpace if it does not yet exist.
  4. Confirm the companyId and wikiId match the space's owner.

Example fix

// before
await resolveSpace(ctx, { companyId, spaceSlug: "research" }); // missing

// after
const { spaces } = await listSpaces(ctx, { companyId });
if (!spaces.some((s) => s.slug === "research")) {
  await createSpace(ctx, { companyId, slug: "research", displayName: "Research" });
}
await resolveSpace(ctx, { companyId, spaceSlug: "research" });
Defensive patterns

Strategy: validation

Validate before calling

async function ensureActiveSpaceExists(ctx, companyId, slug) {
  const { spaces } = await listSpaces(ctx, { companyId });
  if (!spaces.some((s) => s.slug === slug)) {
    throw new Error(`LLM Wiki space not found: ${slug}`);
  }
}

Type guard

function isActiveSpace(space) {
  return !!space && space.status === "active" && !!space.slug;
}

Try / catch

try {
  await resolveSpace(ctx, { companyId, spaceSlug });
} catch (err) {
  if (/LLM Wiki space not found/.test(err.message)) {
    await createSpace(ctx, { companyId, slug: spaceSlug, displayName: spaceSlug });
    return resolveSpace(ctx, { companyId, spaceSlug });
  }
  throw err;
}

Prevention

When it happens

Trigger: Calling any space-scoped API (updatePaperclipIngestionProfile, resolveSpace, etc.) with a spaceSlug that was never created, was archived, or belongs to a different company/wiki.

Common situations: 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.

Related errors


AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12). Data as JSON: /api/errors/eb1853c8b803a278. Report an issue: GitHub.