Skip to content

fix: prevent empty descriptions from being serialized as YAML null in frontmatter#1070

Merged
dyoshikawa merged 1 commit intodyoshikawa:mainfrom
r1bilski:fix-empty-frontmatter-description
Feb 16, 2026
Merged

fix: prevent empty descriptions from being serialized as YAML null in frontmatter#1070
dyoshikawa merged 1 commit intodyoshikawa:mainfrom
r1bilski:fix-empty-frontmatter-description

Conversation

@r1bilski
Copy link
Contributor

closes #1068

@cm-dyoshikawa
Copy link
Collaborator

/oc review

@github-actions
Copy link
Contributor

All CI checks pass. Here's my review:


PR #1070 Review: Fix empty descriptions serialized as YAML null

Summary

This PR fixes issue #1068 where empty descriptions were being serialized as YAML null in frontmatter, causing Zod validation errors since z.optional(z.string()) does not accept null.

Changes Analysis

Core Fix - src/utils/frontmatter.ts:67-73

  • Added deepRemoveNullishObject() call in parseFrontmatter() to strip null/undefined values
  • Ensures YAML bare keys like description: (which parse as null) are removed before Zod validation
  • Consistent with existing stringifyFrontmatter() behavior

Downstream Updates

  • rulesync-rule.ts:162 - Removed ?? "" fallback, now preserves undefined
  • tool-rule.ts:177 - Same change for consistency
  • cursor-rule.ts:92 - Changed !== undefined to truthy check to also skip empty strings

Test Coverage

Excellent coverage added:

  • Null stripping in frontmatter.test.ts (top-level and nested)
  • Cursor rule roundtrip tests verifying no description: in output
  • Re-import tests for YAML null description files
  • Existing tests updated to expect undefined

Verdict

Approved. The implementation is correct, well-tested, and all 3821 tests pass. The fix properly handles the YAML parsing quirk where bare keys produce null values.

github run

@dyoshikawa dyoshikawa merged commit 2f3b43c into dyoshikawa:main Feb 16, 2026
6 checks passed
@r1bilski r1bilski deleted the fix-empty-frontmatter-description branch February 16, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cursor rule generation outputs empty description: when source has no description, breaking re-import

3 participants