{"record":{"id":"309350016e66987d","repo":"continuedev/continue","slug":"error-parsing-markdown-frontmatter","errorCode":null,"errorMessage":"Error parsing markdown frontmatter:","messagePattern":"Error parsing markdown frontmatter:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/config-yaml/src/markdown/markdownToRule.ts","lineNumber":42,"sourceCode":"  // Normalize line endings to \\n\n  const normalizedContent = content.replace(/\\r\\n/g, \"\\n\");\n\n  // More reliable frontmatter detection\n  const parts = normalizedContent.split(/^---\\s*$/m);\n\n  // If we have at least 3 parts (before ---, frontmatter, after ---), we have frontmatter\n  if (parts.length >= 3) {\n    const frontmatterStr = parts[1];\n    // Join the remaining parts back together (in case there are more --- in the markdown)\n    const markdownContent = parts.slice(2).join(\"---\");\n\n    try {\n      // Parse YAML frontmatter\n      const frontmatter = YAML.parse(frontmatterStr) || {}; // Handle empty frontmatter\n      return { frontmatter, markdown: markdownContent.trim() };\n    } catch (e) {\n      // Error parsing frontmatter, treat as markdown only\n      console.warn(\"Error parsing markdown frontmatter:\", e);\n      return { frontmatter: {}, markdown: normalizedContent };\n    }\n  }\n\n  // No frontmatter found\n  return { frontmatter: {}, markdown: normalizedContent };\n}\n\nexport function getRuleName(\n  frontmatter: RuleFrontmatter,\n  id: PackageIdentifier,\n): string {\n  if (frontmatter.name) {\n    return frontmatter.name;\n  }\n\n  const displayName = packageIdentifierToDisplayName(id);\n","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/packages/config-yaml/src/markdown/markdownToRule.ts#L24-L60","documentation":"parseMarkdownRule splits a markdown file's YAML frontmatter (between --- delimiters) and parses it with YAML.parse. If the frontmatter block is syntactically invalid YAML, the error is caught, a warning is printed, and the file is treated as markdown-only with empty frontmatter {} — meaning any rule metadata (name, description, rules) in that block is silently lost.","triggerScenarios":"Calling parseMarkdownRule on a .md file whose frontmatter contains YAML syntax errors: unquoted colons in values, bad indentation, tabs, duplicate keys, or a stray --- inside the block.","commonSituations":"Hand-editing rule markdown files; copy-pasting rules with smart quotes or non-breaking spaces; values containing ': ' unquoted (e.g. `description: Use this: always`).","solutions":["Paste the frontmatter block into a YAML validator or run `yamllint` on the file to find the syntax error","Quote scalar values containing colons or special characters: `description: \"Use this: always\"`","Use spaces (never tabs) for indentation inside frontmatter","Verify a single opening and closing --- delimiter and no stray --- lines inside the block"],"exampleFix":"# before\n---\ntitle: Rule: my rule\n---\n\n# after\n---\ntitle: \"Rule: my rule\"\n---","handlingStrategy":"fallback","validationCode":"const fm = raw.match(/^---\\n([\\s\\S]*?)\\n---/);\nif (fm) YAML.parse(fm[1]); // throws early if invalid","typeGuard":null,"tryCatchPattern":"try {\n  const { frontmatter } = parseMarkdownRule(content);\n  if (Object.keys(frontmatter).length === 0 && content.startsWith(\"---\")) {\n    // frontmatter existed but failed to parse — surface to author\n  }\n} catch { /* parser is non-throwing; guard empty result instead */ }","preventionTips":["Lint markdown frontmatter in CI with yamllint","Quote values containing colons","Check parse results for empty frontmatter on files known to define rules"],"tags":["markdown","frontmatter","yaml","parsing"],"backgroundTag":"yaml-frontmatter-parse-error","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}