Skip to content

Normalize CRLF line endings before splitting YAML blocks - #94

Merged
nonprofittechy merged 1 commit into
mainfrom
fix/crlf-document-separators
Oct 6, 2026
Merged

nonprofittechy merged 1 commit into
mainfrom
fix/crlf-document-separators

Conversation

@nonprofittechy

Copy link
Copy Markdown
Member

Fixes the spurious parse error reported in SuffolkLITLab/docassemble-ALWeaver#1169.

Cause

find_errors_from_string splits blocks with ^--- *$. When a file has CRLF line endings and is passed in as a raw string (as the Weaver does), each separator is ---\r, which doesn't match. The whole file is then parsed as one block, and ruamel reports expected a single document in the stream ... but found another document at line 1. The CLI never showed this because open() in text mode already converts CRLF to LF.

Reproduced with docassemble-CLAGuardianship's Bond_MPC_801.yml (CRLF).

Fix

Convert \r\n and lone \r to \n at the start of find_errors_from_string, matching what find_errors() gets from open(). The line count doesn't change, so reported line numbers stay the same.

Tests

  • Added test_crlf_document_separators_split_blocks, which checks that CRLF input gives the same findings as LF input. It fails without the fix.
  • Full suite: 647 passed.

🤖 Generated with Claude Code

Raw string callers such as the Weaver pass content with CRLF intact, so
"---\r" separators did not match and the whole file was parsed as one
block, producing a spurious "expected a single document" error at line 1.

Refs SuffolkLITLab/docassemble-ALWeaver#1169

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nonprofittechy
nonprofittechy merged commit 7b162e9 into main Oct 6, 2026
2 checks passed
@nonprofittechy
nonprofittechy deleted the fix/crlf-document-separators branch October 6, 2026 14:54
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.

1 participant