Skip to content

fix: build-report reads files with Windows line endings - #15

Open
rafaelgaropaba83-gif wants to merge 1 commit into
alextnetto:mainfrom
rafaelgaropaba83-gif:fix/build-report-crlf
Open

rafaelgaropaba83-gif wants to merge 1 commit into
alextnetto:mainfrom
rafaelgaropaba83-gif:fix/build-report-crlf

Conversation

@rafaelgaropaba83-gif

Copy link
Copy Markdown

Problem

build-report.mjs (and so pack-kb.mjs) crashes on any knowledge base whose rule files end lines with CRLF:

TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))
    at renderRuleFile (build-report.mjs:589)

renderRuleFile splits the file on \n and matches the heading with /^#{2,6}\s+(R-\d{3})\b\s*(.*)$/. On a CRLF file the line ends in \r, which . does not match, so the match returns null.

CRLF files are the normal case on Windows: Git for Windows checks out with core.autocrlf=true, and many Windows editors and scripts write CRLF. Reproduced on Windows 11, Node 22.17.0:

  • node skills/reverse-engineering-saas/scripts/build-report.mjs examples/clickup on a fresh Windows clone of main crashes with the error above.
  • A real study written on Windows hit the same crash at pack-kb.

Fix

read() in build-report.mjs normalizes \r\n and lone \r to \n, so every parser in the report sees the same text on every platform. One line; no behavior change for LF files.

Test

New test build-report reads files with Windows line endings writes a rule file and a screen file with CRLF and checks that the rule card renders and that no \r reaches the page. It fails on main with the error above and passes with the fix.

Full tests/kb-scripts.test.mjs on Windows: 27/27 pass when combined with the path-separator fix from #7 (or #14). Without it, the 10 failures are the check-kb path issue those PRs address, not this change. #12 (Windows CI) would catch both.

🤖 Generated with Claude Code

A knowledge base checked out on Windows (git core.autocrlf) or written by
Windows tools has CRLF line endings. The rule heading regex in
renderRuleFile does not match a line ending in \r, so build-report and
pack-kb crash with "object null is not iterable". The ClickUp example
fails the same way when the repository is cloned on Windows.

read() now normalizes CRLF and lone CR to LF, so every parser in the
report sees the same text on every platform. A regression test writes a
rule file and a screen file with CRLF and checks the rule card renders.

This branch has not been deployed

No deployments
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