fix(backend): emit LF-only OpenAPI spec to avoid phantom Windows CRLF diffs - #1503
Merged
Junirezz merged 1 commit intoOct 2, 2026
Merged
Conversation
generate:openapi preserved the EOL already present in backend/openapi.json, so on Windows a CRLF working copy was re-written as CRLF. Regeneration then left the file flagged as modified while `git diff` was empty — a phantom change caused purely by CRLF/LF normalization. Always write LF, pin generated artifacts to `text eol=lf` in .gitattributes, and add a validator + test that fails on CRLF in generated artifacts. Closes Junirezz#1374
|
@simonpeters298 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1374
Problem
backend/openapi.jsonis reported as modified (M) afternpm run generate:openapion Windows even though the file is byte-identical toHEAD— only CRLF/LF normalization differs. This produces phantom working-tree changes that make it hard to tell whether the spec actually drifted.Root cause
backend/scripts/generate-openapi.tspreserved whatever line ending the existing output file happened to have:Once
openapi.jsonhad CRLF in the working tree (a Windows editor, or a legacy checkout from before.gitattributesexisted), every regeneration rewrote it as CRLF. Git then flagged the file as modified while the diff was empty:Fix
backend/scripts/generate-openapi.ts— always write LF. Output is now platform-independent and matches the repository's.gitattributes(* text=auto eol=lf). Removed the now-unusedosimport..gitattributes— pin generated artifacts with an explicittext eol=lf(backend/openapi.json,backend/schema-snapshots/*.json,docs/schemas/webhooks/*.json) so they are always treated as text and checked out as LF.scripts/validate-generated-artifacts.ts+ test — new guard that fails if any committed generated artifact contains CRLF. Wired aspnpm validate:line-endings/pnpm test:validate-line-endings.Verification
vitest run scripts/validate-generated-artifacts.test.ts-> 4/4 passing (8/8 together with the existing image-size tests).git check-attrnow reportstext: set/eol: lffor the generated artifacts.backend/openapi.jsonitself is unchanged — it was already LF, so there is zero artifact churn.Mwith an empty diff, whereas an LF working copy is clean, and the generator now always writes LF.Notes
generate-openapi.tshad the EOL-preserving heuristic; the schema-snapshot and webhook JSON-schema generators already write LF.git add --renormalizeremains the escape hatch, which is inherent Git behavior.