Skip to content

fix: keep a non-UTF-8 config.ini intact after PR #130 - #144

Merged
yumiaura merged 1 commit into
0.1.37from
fix/config-legacy-encoding
Sep 30, 2026
Merged

yumiaura merged 1 commit into
0.1.37from
fix/config-legacy-encoding

Conversation

@yumiaura

Copy link
Copy Markdown
Owner

Summary

PR #130 (merged into 0.1.37) made the LLM, Ollama, vendor and image-generation settings read config.ini as strict UTF-8. On a Windows install whose config.ini was written earlier in the locale codec (cp1251, cp949, gbk) and holds non-ASCII text, the first save after the upgrade fails to read the file, carries on with an empty parser and rewrites config.ini with only its own section. Reproduced on #130: a cp1251 file with [window], [github] and [generation] is left with only [llm] after save_llm_enabled(True).

config_store already had the locale-codec fallback; the other readers did not use it.

  • config_store: _read_text renamed to read_config_text (no underscore-prefixed names in this project).
  • ai_backends, github_notify, llm_prompt, llm_vendors, main, settings_ui, shop_api: every config.ini read goes through config_store.read_config_text; the handlers catch OSError (which ConfigParser.read() used to swallow) instead of the UnicodeDecodeError the shared reader no longer raises.
  • tests/test_legacy_config_keeps_its_sections.py: a cp1251 config.ini keeps every section through each of the four savers.
  • CHANGELOG: an Unreleased section with entries for PR Two small correctness fixes: file permissions, and text encoding #130 and for this fix.

Test plan

  • The new test fails on 0.1.37 without this fix (4 failed) and passes with it
  • ruff check mycat tests clean
  • Full suite (pytest --forked --timeout=60 --timeout-method=thread) passes locally
  • CI green

PR #130 made the LLM, Ollama, vendor and image-generation settings read
config.ini as strict UTF-8. A config.ini written earlier in the locale
codec (cp1251, cp949, gbk) with non-ASCII text then fails to read, the
writer carries on with an empty parser and rewrites the file with only
its own section: the window position, the GitHub token and the prompt
are lost. config_store already had the locale-codec fallback; the other
readers did not use it.

- config_store: rename _read_text to read_config_text (no underscore
  names in this project) and use it from every config reader
- ai_backends, github_notify, llm_prompt, llm_vendors, main, settings_ui,
  shop_api: read through config_store.read_config_text; catch OSError,
  which ConfigParser.read() used to swallow, instead of the
  UnicodeDecodeError the shared reader no longer raises
- tests: a cp1251 config.ini keeps every section through each save
- CHANGELOG: Unreleased entries for PR #130 and for this fix
@yumiaura
yumiaura merged commit f231d43 into 0.1.37 Sep 30, 2026
3 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.

1 participant