🐛 Fixed block scalars being added to downloaded redirects#28480
Conversation
ref https://linear.app/ghost/issue/ONC-1827/block-scalars-being-added-to-redirects - downloading redirects as YAML rewrote long URL values into `>-` folded block scalars that the user never authored, causing confusion - root cause: js-yaml's `yaml.dump` defaults to lineWidth 80, folding any line longer than that - pass `{lineWidth: -1}` to disable folding so values are emitted verbatim; values with real newlines still use a literal block scalar and round-trip correctly through parseYaml
|
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 (2)
WalkthroughThis PR fixes YAML serialization in the redirect config parser by disabling line folding. The Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsStopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a Comment |
ref ONC-1827
Problem
Downloading redirects as YAML rewrote long URL values into
>-folded block scalars that the user never authored:This didn't break redirects, but it injected undocumented markup into the user's file, causing confusion (reported by a customer who edited the markup out, re-uploaded, and saw Ghost add it back on the next download).
Root cause
serializeToYamlinredirect-config-parser.tscallsyaml.dump(), which defaults to js-yaml'slineWidth: 80. Any value longer than 80 chars gets folded into a block scalar.Fix
Pass
{lineWidth: -1}to disable line folding, so values are emitted verbatim on a single line. Values containing real newlines still use a literal block scalar (|-) and round-trip correctly throughparseYaml.Testing
Added a red/green unit test (
does not fold long values into block scalars) asserting a longtoURL produces no>-markup and round-trips intact. Verified the test fails without the fix and passes with it. All 23redirect-config-parsertests pass.🤖 Generated with Claude Code