Repository navigation
acc: make update_file.py replace bytes to preserve line endings - #6944
Merged
Merged
Conversation
update_file.py opened the file in text mode. On Windows that reads CRLF as LF and writes every LF back as CRLF, so an LF file (e.g. *.txt, which .gitattributes pins to eol=lf, or files written by printf/envsubst) came back with CRLF line endings. That changes the file's hash and upload payload beyond the intended edit. Read and write bytes instead. When the file already uses CRLF, convert "\n" in OLD/NEW to "\r\n" so multi-line replacements keep matching on Windows checkouts with core.autocrlf=true. Co-authored-by: Isaac <no-reply@databricks.com>
Collaborator
Integration test reportCommit: f354421
Top 6 slowest tests (at least 2 minutes):
|
denik
approved these changes
Oct 6, 2026
denik
reviewed
Oct 6, 2026
On a CRLF file, "\n" in OLD/NEW was converted to "\r\n" unconditionally, so an argument that already had "\r\n" became "\r\r\n". Normalize to "\n" first, then convert. Co-authored-by: Isaac <no-reply@databricks.com>
Sankalp-Mittal
enabled auto-merge
October 6, 2026 13:00
Sankalp-Mittal
disabled auto-merge
October 6, 2026 13:01
Sankalp-Mittal
enabled auto-merge
October 6, 2026 13:07
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.
Changes
acceptance/bin/update_file.pynow reads and writes the file as bytes, so only the matched bytes change. If the file already uses CRLF,\nin OLD/NEW is converted to\r\nso multi-line replacements still match.Why
Text mode on Windows reads CRLF as LF and writes every LF back as CRLF. An LF file (
*.txtis pinned toeol=lfinacceptance/.gitattributes, and files written byprintf/envsubstare LF) came back with CRLF after any edit. That changes the file's hash and upload payload beyond the intended edit.bundle/resources/job_runs/on_file_change_globalready works around this withprintfinstead ofupdate_file.py.Windows runners check out with
core.autocrlf=true, so checked-indatabricks.ymlfiles are CRLF there. About 10 scripts pass multi-line OLD strings (e.g.clusters/libraries-update,job_runs/on_file_change,migrate/auto/clean). These used to match through text mode's newline translation, and the CRLF conversion keeps them matching.Tests
migrate/auto/clean,migrate/auto/direct-only,clusters/libraries-update,clusters/deploy/update-and-resize-autoscale,job_runs/on_file_change,job_runs/on_bundle_deploy,pipelines/destroy/destroy-pipeline-cascade,resource_deps/immutable_field_ref,postgres_branches/update_expire_time.This pull request and its description were written by Isaac.