paperclipai/paperclip · error · Error

spaceSlug is required

Error message

spaceSlug is required

What it means

Thrown by normalizeSpaceSlug() when, after trimming/lowercasing/collapsing non-[a-z0-9] characters to hyphens and stripping leading/trailing hyphens, the resulting slug is empty. DEFAULT_SPACE_SLUG ("default") is only used as the fallback when the input itself is blank — so reaching this branch means the input contained characters but none survived normalization (e.g. all punctuation/unicode).

Source

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

function requireString(value: unknown, name: string): string {
  const field = stringField(value);
  if (!field) throw new Error(`${name} is required`);
  return field;
}

function normalizeWikiId(value: unknown): string {
  return stringField(value) ?? DEFAULT_WIKI_ID;
}

export function normalizeSpaceSlug(value: unknown): string {
  const raw = stringField(value) ?? DEFAULT_SPACE_SLUG;
  const normalized = raw
    .trim()
    .toLowerCase()
    .replace(/[^a-z0-9]+/g, "-")
    .replace(/^-+|-+$/g, "");
  if (!normalized) throw new Error("spaceSlug is required");
  if (normalized.length > 64) throw new Error("spaceSlug must be 64 characters or fewer");
  return normalized;
}

async function requirePaperclipIngestionPolicy(
  ctx: PluginContext,
  input: { companyId: string; wikiId: string; spaceSlug?: string | null },
  purpose: PaperclipIngestionPolicyPurpose,
  options: { requireEnabledProfile?: boolean } = {},
): Promise<WikiSpace> {
  const space = await resolveSpace(ctx, {
    companyId: input.companyId,
    wikiId: input.wikiId,
    spaceSlug: input.spaceSlug,
  });
  const profile = await profileForSpace(ctx, input.companyId, space);
  const decision = evaluatePaperclipProfilePolicy({
    space,

View on GitHub (pinned to 67001ec6eb)

Solutions

  1. Provide a spaceSlug that contains at least one ASCII letter or digit (a-z, 0-9).
  2. Transliterate the source title to ASCII before deriving the slug (e.g. via a slugify library that maps unicode to ascii).
  3. Omit spaceSlug to fall back to DEFAULT_SPACE_SLUG if the default space is acceptable.

Example fix

// before
const slug = normalizeSpaceSlug("---!!!..."); // throws
// after
const slug = normalizeSpaceSlug("Team Notes"); // -> "team-notes"
Defensive patterns

Strategy: validation

Validate before calling

import { normalizeSpaceSlug } from "@paperclipai/plugin-llm-wiki/wiki/core";
function safeSlug(input: string): string {
  // pre-check: at least one ascii alphanumeric survives
  if (!/[a-z0-9]/i.test(input)) return "default"; // or throw with a clearer message
  return normalizeSpaceSlug(input);
}

Type guard

function slugWillNormalizeNonempty(v: string): boolean {
  return /[a-z0-9]/i.test(v);
}

Try / catch

try {
  slug = normalizeSpaceSlug(userInput);
} catch (err) {
  if (err instanceof Error && err.message === "spaceSlug is required") {
    slug = "default"; // or prompt user for a valid name
  } else throw err;
}

Prevention

When it happens

Trigger: Passing a spaceSlug composed entirely of non-alphanumeric characters (e.g. "---", "...", "!!!", emoji, or CJK characters that the regex [^a-z0-9] collapses to hyphens and then strips). Passing whitespace-only input that the stringField fallback did not catch because it was technically non-empty.

Common situations: User types a space name using only symbols or non-Latin characters. Slug auto-derived from a title that contained no ASCII alphanumerics. Test fixtures with degenerate slug strings.

Related errors


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