rulesync icon indicating copy to clipboard operation
rulesync copied to clipboard

improvement: include file path in frontmatter YAML parse error messages

Open saitota opened this issue 9 months ago • 1 comments

Summary

When a YAML syntax error occurs in a frontmatter during rulesync import, the error message does not indicate which file caused the error. This makes it difficult to identify the problematic file when importing a large number of rule files.

Steps to Reproduce

  1. Prepare a rule file with invalid YAML in its frontmatter (e.g., an unquoted string containing a colon such as description: foo : bar)
  2. Run rulesync import --targets claudecode --global --features "*"

Current Behavior

ERROR  YAMLException: incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line at line 2, column 22:
    description: foo : bar
                         ^

Expected Behavior

ERROR  Failed to parse frontmatter in .rulesync/rules/example.md: YAMLException: incomplete explicit mapping pair; ...

Notes

  • The parseFrontmatter function in src/utils/frontmatter.ts accepts an optional filePath second argument. When filePath is not provided, the original error is re-thrown as-is without file information. Callers need to pass filePath to get meaningful error messages.

  • Related: #1043 — PR #1052 addressed Zod validation and file-not-found errors, but parseFrontmatter YAML parse errors were not covered.

saitota avatar Feb 25 '26 01:02 saitota

@saitota Thank you! Your point is true exactly. If you contribute this, I will be glad.

cm-dyoshikawa avatar Feb 25 '26 01:02 cm-dyoshikawa