{"record":{"id":"4ec9ea8d89ba3236","repo":"paperclipai/paperclip","slug":"spaceslug-is-required","errorCode":null,"errorMessage":"spaceSlug is required","messagePattern":"spaceSlug is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/plugins/plugin-llm-wiki/src/wiki/core.ts","lineNumber":452,"sourceCode":"\nfunction requireString(value: unknown, name: string): string {\n  const field = stringField(value);\n  if (!field) throw new Error(`${name} is required`);\n  return field;\n}\n\nfunction normalizeWikiId(value: unknown): string {\n  return stringField(value) ?? DEFAULT_WIKI_ID;\n}\n\nexport function normalizeSpaceSlug(value: unknown): string {\n  const raw = stringField(value) ?? DEFAULT_SPACE_SLUG;\n  const normalized = raw\n    .trim()\n    .toLowerCase()\n    .replace(/[^a-z0-9]+/g, \"-\")\n    .replace(/^-+|-+$/g, \"\");\n  if (!normalized) throw new Error(\"spaceSlug is required\");\n  if (normalized.length > 64) throw new Error(\"spaceSlug must be 64 characters or fewer\");\n  return normalized;\n}\n\nasync function requirePaperclipIngestionPolicy(\n  ctx: PluginContext,\n  input: { companyId: string; wikiId: string; spaceSlug?: string | null },\n  purpose: PaperclipIngestionPolicyPurpose,\n  options: { requireEnabledProfile?: boolean } = {},\n): Promise<WikiSpace> {\n  const space = await resolveSpace(ctx, {\n    companyId: input.companyId,\n    wikiId: input.wikiId,\n    spaceSlug: input.spaceSlug,\n  });\n  const profile = await profileForSpace(ctx, input.companyId, space);\n  const decision = evaluatePaperclipProfilePolicy({\n    space,","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/packages/plugins/plugin-llm-wiki/src/wiki/core.ts#L434-L470","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Provide a spaceSlug that contains at least one ASCII letter or digit (a-z, 0-9).","Transliterate the source title to ASCII before deriving the slug (e.g. via a slugify library that maps unicode to ascii).","Omit spaceSlug to fall back to DEFAULT_SPACE_SLUG if the default space is acceptable."],"exampleFix":"// before\nconst slug = normalizeSpaceSlug(\"---!!!...\"); // throws\n// after\nconst slug = normalizeSpaceSlug(\"Team Notes\"); // -> \"team-notes\"","handlingStrategy":"validation","validationCode":"import { normalizeSpaceSlug } from \"@paperclipai/plugin-llm-wiki/wiki/core\";\nfunction safeSlug(input: string): string {\n  // pre-check: at least one ascii alphanumeric survives\n  if (!/[a-z0-9]/i.test(input)) return \"default\"; // or throw with a clearer message\n  return normalizeSpaceSlug(input);\n}","typeGuard":"function slugWillNormalizeNonempty(v: string): boolean {\n  return /[a-z0-9]/i.test(v);\n}","tryCatchPattern":"try {\n  slug = normalizeSpaceSlug(userInput);\n} catch (err) {\n  if (err instanceof Error && err.message === \"spaceSlug is required\") {\n    slug = \"default\"; // or prompt user for a valid name\n  } else throw err;\n}","preventionTips":["Ensure the source name contains at least one ASCII letter or digit.","Transliterate unicode titles to ASCII before slugifying.","Validate in the UI form before submission."],"tags":["llm-wiki","validation","slug","normalization"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}