Bug: dbt-autofix-fix introduces mojibake (�") and then fails with UnicodeDecodeError on Windows
Summary
On Windows, dbt-autofix-fix appears to corrupt punctuation/characters in YAML text (example: introducing �" in-place), and then fails with a Unicode decode error.
Environment
- OS: Windows 11 (
win32 10.0.26100)
- Python: 3.12.12
- pre-commit: 4.5.1
- dbt-autofix hook:
- repo:
https://github.com/dbt-labs/dbt-autofix
- rev:
v0.20.2
- hook id:
dbt-autofix-fix
Hook config
yaml:
repos:
Steps to reproduce
pre-commit install
pre-commit run --all-files
Actual result
- Hook reports file refactors (
replace_fancy_quotes).
- Character corruption is observed in edited text (e.g. unexpected
�" sequence appears where normal punctuation/characters should be; screenshot attached).
- Run then crashes with:
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d ... ... File "...dbt_autofix\refactor.py", line 150, in _apply_changesets yml_str = yml_file.read_text() ... File "...encodings\cp1252.py", line 23, in decode
Expected result
- No mojibake/corruption in file content.
- Hook should consistently handle UTF-8 content and complete without decode errors.

Bug:
dbt-autofix-fixintroduces mojibake (�") and then fails with UnicodeDecodeError on WindowsSummary
On Windows,
dbt-autofix-fixappears to corrupt punctuation/characters in YAML text (example: introducing�"in-place), and then fails with a Unicode decode error.Environment
win32 10.0.26100)https://github.com/dbt-labs/dbt-autofixv0.20.2dbt-autofix-fixHook config
yaml:
repos:
rev: v0.20.2
hooks:
Steps to reproduce
pre-commit installpre-commit run --all-filesActual result
replace_fancy_quotes).�"sequence appears where normal punctuation/characters should be; screenshot attached).UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d ... ... File "...dbt_autofix\refactor.py", line 150, in _apply_changesets yml_str = yml_file.read_text() ... File "...encodings\cp1252.py", line 23, in decodeExpected result