Skip to content

fix(encoding): read pyproject.toml and quant_map.json as UTF-8 - #2190

Merged
debpalash merged 5 commits into
debpalash:mainfrom
kevin9327:fix/version-fallback-pyproject-encoding
Sep 18, 2026
Merged

debpalash merged 5 commits into
debpalash:mainfrom
kevin9327:fix/version-fallback-pyproject-encoding

Conversation

@kevin9327

@kevin9327 kevin9327 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Read bundled pyproject.toml and quant_map.json explicitly as UTF-8 so source startup and generation work on CJK Windows code pages. The corresponding guards and regression fixtures use the same portable decoding.

Current main is merged and the changelog conflict is resolved with contributor credit. Both CodeRabbit and Greptile reviews were checked; neither has an outstanding code finding.

Validation: 50 offline locale-decoding, version, GGUF and changelog tests passed. The contributor’s regressions exercise cp932/cp936/cp949/cp950 without requiring a Windows host.

Bundled pyproject.toml and quant_map.json reads now use explicit UTF-8 decoding, with portable regression coverage for CJK Windows code pages. This prevents source startup and generation failures caused by locale decoding. No outstanding review findings remain.

kevin9327 and others added 2 commits September 18, 2026 07:31
Path.read_text() / Path.open() with no encoding decode in the locale code
page. Both files are UTF-8 (TOML and JSON always are) and carry em dashes
that cp932/cp936/cp949/cp950 cannot decode, so on a Chinese, Japanese or
Korean Windows:

- core.version._fallback_version raised UnicodeDecodeError while
  core.version was still being imported. That is the version path a raw
  source checkout and a frozen build without package metadata both take,
  and it runs at import, so the backend died before any VoiceStudio code
  could name the cause.
- engines.omnivoice_gguf.backend._load_quant_map raised it when the engine
  picked a quant, so every generation failed with an error the app could
  not classify.

tests/test_app_version.py, the version-lockstep guard, read the same files
the same way and could not run on those hosts either.

Same Python 3.11 locale-decoding class as the .pth startup crash (debpalash#1783)
and alembic.ini (debpalash#2075).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 2c08cb36-1c35-49e2-a7d7-4072f3ff00f8

📥 Commits

Reviewing files that changed from the base of the PR and between 7b98105 and 30234fb.

📒 Files selected for processing (1)
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

Repository metadata and quantization data now use explicit UTF-8 decoding. Tests cover CJK Windows code pages and verify the affected files contain valid UTF-8 data. The changelog records the source-install fix.

Changes

Locale-safe decoding

Layer / File(s) Summary
Runtime UTF-8 reads
backend/core/version.py, backend/engines/omnivoice_gguf/backend.py, CHANGELOG.md
Fallback version and quantization metadata reads now specify UTF-8 encoding. The changelog records the fix.
Locale regression coverage
tests/test_app_version.py, tests/test_repo_data_locale_decoding.py, tests/backend/engines/test_omnivoice_gguf.py
Test reads now specify UTF-8. New tests validate version and quantization loading under cp932, cp936, cp949, and cp950, and verify both files decode as UTF-8.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 30234

The repository data reads now use UTF-8 across the affected runtime paths, with targeted locale regression coverage. No merge-blocking risk remains identified.

🚥 Pre-merge checks | ✅ 7 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title uses the required Conventional Commit format with a scope and describes the encoding fix, but it does not include an issue reference. The provided description also does not include the relev… Add the issue reference, such as #2190, to the title or pull request body while preserving the Conventional Commit format.
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 5 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (7 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly states the purpose, changes, and validation results. It omits the template headings, change-type selection, checklist, and release-cadence section, but the core required inform…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Cross-Platform Default Parity ✅ Passed The PR changes default file decoding for pyproject.toml and quant_map.json, but both reads now explicitly use UTF-8. This produces the same decoding on macOS, Windows, and Linux; the prior locale-…
I18n Completeness (21 Locales) ✅ Passed The custom check is not applicable. The authoritative pull-request diff changes only CHANGELOG.md, backend files, and tests; it changes no frontend source file and adds or changes no frontend t('...')…
Local-First Guarantee ✅ Passed The PR changes only local UTF-8 file reads, changelog text, and tests. The production diff adds no cloud calls, accounts, API keys, or telemetry. The existing HuggingFace download path is unchanged an…
Backward Compatibility ✅ Passed The PR changes only UTF-8 decoding for bundled pyproject.toml and quant_map.json, plus tests and a changelog entry. The diff contains no database schema change, Alembic migration requirement, `omn…
Full details: Title check

Explanation

The title uses the required Conventional Commit format with a scope and describes the encoding fix, but it does not include an issue reference. The provided description also does not include the relevant issue reference.

Full details: Docstring Coverage

Explanation

Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 5 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Retrigger

The PR appears safe to merge; no concrete correctness, security, data-risk, or repository-rule violation remains.

Summary

Explicitly decodes bundled TOML and JSON data as UTF-8, preventing locale-dependent startup and OmniVoice GGUF generation failures on CJK Windows code pages.

  • Updates the version fallback and quantization-map loader.
  • Makes related test guards use portable decoding.
  • Adds regression coverage for cp932, cp936, cp949, and cp950 environments.

Reviews (4) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..."

@kevin9327

Copy link
Copy Markdown
Contributor Author

Heads-up on the CHANGELOG: ## [Unreleased] is empty on main, so this PR and my siblings (#2190 / #2191 / #2192) each recreate the Highlights + Fixed scaffold and will collide there. Whichever lands first, I'll re-file the others onto its block — or just drop my two lines at merge time and I'll follow up.

kevin9327 and others added 3 commits September 18, 2026 07:49
The quant-map module's own tests read the same files the backend reads,
with no encoding, so the module errored out on a Chinese, Japanese or
Korean Windows instead of guarding anything. JSON and Python source are
both UTF-8; the source read even re-encodes as UTF-8 on the next line.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@debpalash
debpalash merged commit 02aeff5 into debpalash:main Sep 18, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants