continuedev/continue · warning

Error parsing markdown frontmatter:

Error message

Error parsing markdown frontmatter:

What it means

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.

Source

Thrown at packages/config-yaml/src/markdown/markdownToRule.ts:42

  // Normalize line endings to \n
  const normalizedContent = content.replace(/\r\n/g, "\n");

  // More reliable frontmatter detection
  const parts = normalizedContent.split(/^---\s*$/m);

  // If we have at least 3 parts (before ---, frontmatter, after ---), we have frontmatter
  if (parts.length >= 3) {
    const frontmatterStr = parts[1];
    // Join the remaining parts back together (in case there are more --- in the markdown)
    const markdownContent = parts.slice(2).join("---");

    try {
      // Parse YAML frontmatter
      const frontmatter = YAML.parse(frontmatterStr) || {}; // Handle empty frontmatter
      return { frontmatter, markdown: markdownContent.trim() };
    } catch (e) {
      // Error parsing frontmatter, treat as markdown only
      console.warn("Error parsing markdown frontmatter:", e);
      return { frontmatter: {}, markdown: normalizedContent };
    }
  }

  // No frontmatter found
  return { frontmatter: {}, markdown: normalizedContent };
}

export function getRuleName(
  frontmatter: RuleFrontmatter,
  id: PackageIdentifier,
): string {
  if (frontmatter.name) {
    return frontmatter.name;
  }

  const displayName = packageIdentifierToDisplayName(id);

View on GitHub (pinned to 5522c6f44c)

Solutions

  1. Paste the frontmatter block into a YAML validator or run `yamllint` on the file to find the syntax error
  2. Quote scalar values containing colons or special characters: `description: "Use this: always"`
  3. Use spaces (never tabs) for indentation inside frontmatter
  4. Verify a single opening and closing --- delimiter and no stray --- lines inside the block

Example fix

# before
---
title: Rule: my rule
---

# after
---
title: "Rule: my rule"
---
Defensive patterns

Strategy: fallback

Validate before calling

const fm = raw.match(/^---\n([\s\S]*?)\n---/);
if (fm) YAML.parse(fm[1]); // throws early if invalid

Try / catch

try {
  const { frontmatter } = parseMarkdownRule(content);
  if (Object.keys(frontmatter).length === 0 && content.startsWith("---")) {
    // frontmatter existed but failed to parse — surface to author
  }
} catch { /* parser is non-throwing; guard empty result instead */ }

Prevention

When it happens

Trigger: 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.

Common situations: Hand-editing rule markdown files; copy-pasting rules with smart quotes or non-breaking spaces; values containing ': ' unquoted (e.g. `description: Use this: always`).

Related errors


AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27). Data as JSON: /api/errors/309350016e66987d. Report an issue: GitHub.