fix: pin encoding=utf-8 on text-mode open() reads in TupleFilesystemStoreBackend, InlineStoreBackend, FileDataContext - #12121
Open
CAOShurong wants to merge 1 commit into
Conversation
…toreBackend, InlineStoreBackend, FileDataContext Fixes fivetran#12120: great_expectations wrote store files as UTF-8 unconditionally but read them back with bare open() (locale-ambient). On hosts where the process locale encoding is not UTF-8 (e.g. Windows cp936), this raised UnicodeDecodeError on the very bytes great_expectations itself wrote. Changes: - tuple_store_backend.py:318 _get() open(filepath) -> open(filepath, encoding="utf-8") - inline_store_backend.py:222 _save_changes() write -> open(..., encoding="utf-8") - file_data_context.py:168 _save_project_config() write -> open(..., encoding="utf-8") - file_data_context.py:194 _load_file_backed_project_config() read -> open(..., encoding="utf-8") Adds regression tests that force PYTHONUTF8=0 / LC_ALL=C in a subprocess to trigger the non-UTF-8 codepage and assert the bug is fixed. AI-assisted: yes (Hermes General agent, autonomous loop round v6)
👷 Deploy request for niobium-lead-7998 pending review.Visit the deploys page to approve it
|
Contributor
|
Thank you for your contribution! Before we can merge this pull request, every committer needs to have signed our Contributor License Agreement (CLA). We could not find a signed CLA for: @CAOShurong. Please sign the Individual Contributor License Agreement, or the Software Grant and Corporate Contributor License Agreement if you are contributing on behalf of your employer (see CLA.md for details). Once resolved, comment |
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.
Fixes #12120: great_expectations wrote store files as UTF-8 unconditionally but read them back with bare
open()(locale-ambient). On hosts where the process locale encoding is not UTF-8 (e.g. Windows cp936), this raisedUnicodeDecodeErroron the very bytes great_expectations itself wrote.Changes
tuple_store_backend.py:318_get()open(filepath)→open(filepath, encoding="utf-8")inline_store_backend.py:222_save_changes()write →open(..., encoding="utf-8")file_data_context.py:168_save_project_config()write →open(..., encoding="utf-8")file_data_context.py:194_load_file_backed_project_config()read →open(..., encoding="utf-8")Verification
open()raisedUnicodeDecodeError: 'gbk' codec can't decode byte 0x94/0xadon the non-ASCII UTF-8 bytes the write path emitted.encoding="utf-8"pinned on the four text-modeopen()calls, round-trips succeed under forcedPYTHONUTF8=0 / LC_ALL=C.Regression tests
Added two tests that run under
PYTHONUTF8=0 / LC_ALL=Cto force the non-UTF-8 codepage:test_tuple_store_backend_utf8_pinned_read_roundtripintests/data_context/store/test_store_backends.pytest_file_data_context_utf8_pinned_yml_loadintests/data_context/test_loading_and_saving_of_data_context_configs.pyBoth fail against unpatched
developand pass with the fix.AI-assisted: yes (Hermes General agent, autonomous loop round v6)