{"record":{"id":"16ed8d9304f39975","repo":"paperclipai/paperclip","slug":"wiki-page-path-must-be-a-markdown-file-path","errorCode":null,"errorMessage":"Wiki page path must be a markdown file: ${path}","messagePattern":"Wiki page path must be a markdown file: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/plugins/plugin-llm-wiki/src/wiki/core.ts","lineNumber":1188,"sourceCode":"    trimmed !== \"IDEA.md\" &&\n    trimmed !== \"index.md\" &&\n    trimmed !== \"log.md\" &&\n    !trimmed.startsWith(\"raw/\") &&\n    !trimmed.startsWith(\"wiki/\") &&\n    !(options.allowMetadata && trimmed.startsWith(\".paperclip/\"))\n  ) {\n    throw new Error(`Wiki path must stay inside AGENTS.md, IDEA.md, raw/, or wiki/: ${path}`);\n  }\n  return trimmed;\n}\n\nfunction assertPagePath(path: string): string {\n  const normalized = assertWikiPath(path);\n  if (normalized !== \"index.md\" && normalized !== \"log.md\" && normalized !== \"WIKI.md\" && normalized !== \"AGENTS.md\" && normalized !== \"IDEA.md\" && !normalized.startsWith(\"wiki/\")) {\n    throw new Error(`Wiki page writes must target AGENTS.md, IDEA.md, or wiki/: ${path}`);\n  }\n  if (!normalized.endsWith(\".md\")) {\n    throw new Error(`Wiki page path must be a markdown file: ${path}`);\n  }\n  return normalized;\n}\n\nfunction assertPageWriteAllowed(path: string, writer: WritePageInput[\"writer\"] = \"agent_tool\"): void {\n  if (writer !== \"board_ui\" && PROTECTED_WIKI_CONTROL_FILES.has(path)) {\n    throw new Error(`Refusing to overwrite protected wiki control file ${path}; board-managed edits must use the wiki UI.`);\n  }\n}\n\nfunction assertRawPath(path: string): string {\n  const normalized = assertWikiPath(path);\n  if (!normalized.startsWith(\"raw/\")) {\n    throw new Error(`Source path must stay inside raw/: ${path}`);\n  }\n  return normalized;\n}\n","sourceCodeStart":1170,"sourceCodeEnd":1206,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/packages/plugins/plugin-llm-wiki/src/wiki/core.ts#L1170-L1206","documentation":"Thrown by assertPagePath when the normalized path passes the location check but does not end with '.md'. Enforces that page writes are markdown only.","triggerScenarios":"Calling writePage with a path like 'wiki/notes.txt', 'wiki/index', or 'wiki/data.json'.","commonSituations":"Forgetting the extension; importing a non-markdown file via the page API; auto-generated path missing its suffix.","solutions":["Append '.md' to the filename before calling writePage.","Route non-markdown content to the raw-source API under raw/ instead.","Validate the extension at the form boundary."],"exampleFix":"// before\nawait writePage(ctx, { companyId, path: \"wiki/notes\" });\n\n// after\nawait writePage(ctx, { companyId, path: \"wiki/notes.md\" });","handlingStrategy":"validation","validationCode":"function ensureMarkdownExtension(path) {\n  const t = String(path).trim().replace(/^\\/+/, \"\");\n  if (!t.endsWith(\".md\")) throw new Error(`Wiki page path must be a markdown file: ${path}`);\n  return t;\n}","typeGuard":"function isMarkdownPath(path) {\n  return String(path ?? \"\").trim().replace(/^\\/+/, \"\").endsWith(\".md\");\n}","tryCatchPattern":"try {\n  await writePage(ctx, { companyId, path, content });\n} catch (err) {\n  if (/must be a markdown file/.test(err.message)) {\n    return writePage(ctx, { companyId, path: `${path}.md`, content });\n  }\n  throw err;\n}","preventionTips":["Always append .md when constructing page paths.","Route non-markdown content to raw/.","Validate extension at the form boundary."],"tags":["validation","wiki","paths","paperclip"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}