paperclipai/paperclip · error · Error

spaceSlug must be 64 characters or fewer

Error message

spaceSlug must be 64 characters or fewer

What it means

Thrown by normalizeSpaceSlug() when the normalized slug (after lowercasing, collapsing separators, and trimming hyphens) exceeds 64 characters. The 64-char cap keeps slugs URL-safe and consistent with the space id derivation downstream (stableSpaceId hashes the slug). This runs after the empty-check, so the slug is non-empty but too long.

Source

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

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,
    profile,

View on GitHub (pinned to 67001ec6eb)

Solutions

  1. Shorten the input to keep the normalized slug at or below 64 characters.
  2. Truncate before calling normalizeSpaceSlug() (and ideally strip on a word boundary to avoid trailing hyphens).
  3. Validate slug length in the UI form before submission.

Example fix

// before
const slug = normalizeSpaceSlug(veryLongTitle); // throws if normalized > 64 chars
// after
const truncated = veryLongTitle.slice(0, 64);
const slug = normalizeSpaceSlug(truncated);
Defensive patterns

Strategy: validation

Validate before calling

const MAX_SLUG = 64;
function normalizeAndTruncate(raw: string): string {
  const truncated = raw.slice(0, MAX_SLUG);
  return normalizeSpaceSlug(truncated);
}

Type guard

function slugWithinLimit(raw: string): boolean {
  // optimistic: pre-truncate and re-measure
  const n = raw.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
  return n.length <= 64;
}

Try / catch

try {
  slug = normalizeSpaceSlug(longInput);
} catch (err) {
  if (err instanceof Error && err.message.includes("64 characters")) {
    slug = normalizeSpaceSlug(longInput.slice(0, 64));
  } else throw err;
}

Prevention

When it happens

Trigger: Passing a long space name or pre-slugified string whose normalized form is 65+ chars. Auto-generating a slug from a verbose title without truncation.

Common situations: User creates a space with a very long display name and the slug is derived verbatim. Copy-pasting a paragraph into the slug field. Imported data with unbounded slug strings.

Related errors


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