Skip to content

Bug: dbt-autofix-fix introduces mojibake (�") and then fails with UnicodeDecodeError on Windows #366

Description

@tonyhoang-cot

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

  1. pre-commit install
  2. 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.
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions