fix(adapters): escape carriage returns in YAML frontmatter and dedupe escapeYamlValue#1240
fix(adapters): escape carriage returns in YAML frontmatter and dedupe escapeYamlValue#1240zied-jlassi wants to merge 1 commit into
Conversation
… escapeYamlValue escapeYamlValue detected \r as a character requiring quoting but never escaped it, leaving a literal carriage return inside the double-quoted scalar. A literal CR there is subject to YAML line folding/normalization and could silently corrupt the round-tripped value (realistic with CRLF-authored command descriptions). - Escape \r as \r alongside the existing \, " and \n handling. - Extract the helper, previously duplicated verbatim across five adapters (bob, claude, cursor, pi, windsurf), into a shared command-generation/yaml.ts module. - Add unit tests covering the escaping rules and a round-trip through a real YAML parser. Refs Fission-AI#1205, Fission-AI#1204
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughA new shared module ChangesYAML utility extraction and adapter migration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
escapeYamlValueflags\r(carriage return) as a character that requires quoting, but never escapes it. The value is wrapped in double quotes with a literal CR left inside the scalar. A literal carriage return inside a double-quoted YAML scalar is subject to line folding/normalization, so the value can be silently corrupted when the generated frontmatter is read back — realistic when a commandname/description/category/tagis authored with CRLF (Windows) line endings.This also extracts the helper, which is currently duplicated verbatim across five adapters, into a single shared module.
The bug (before)
So
escapeYamlValue("Line 1\rLine 2")produced"Line 1<CR>Line 2"(literal CR inside quotes) instead of"Line 1\rLine 2".What changed
\ras\ralongside the existing\\,"and\nhandling.bob.ts,claude.ts,cursor.ts,pi.tsandwindsurf.ts. It now lives once insrc/core/command-generation/yaml.tsand is imported by all five. No behavior change for those adapters beyond the\rfix.test/core/command-generation/yaml.test.tscovers the escaping rules and round-trips values (plain / colon / quotes / backslash /\n/\r/ CRLF / mixed) through a real YAML parser (yaml) to assert the value survives.Testing
pnpm testfor the touched area:yaml.test.ts(16) +adapters.test.ts(92) → 108 passing.eslint src/core/command-generation/→ clean.pnpm run build(tsc) → compiles.pnpm test: all command-generation tests pass. I saw two unrelated timeouts intest/commands/initiative.test.tsunder full-suite load; they pass on a pristine checkout (running ~6.5–7.3s, just under the 10s timeout) and are independent of this change (it only touches YAML escaping). Flagging transparently in case CI flakes there.Closes #1205
Closes #1204
Summary by CodeRabbit