mirror of
https://github.com/open-webui/computer.git
synced 2026-11-05 01:17:24 +00:00
[GH-ISSUE #313] bug: save_config() does not escape newlines -> invalid config.toml -> silent loss of all config sections (incl. server.secret) #227
Labels
No labels
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
open-webui/computer#227
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @adonay52-svg on GitHub (Oct 9, 2026).
Original GitHub issue: https://github.com/open-webui/computer/issues/313
Summary
save_config()incptr/utils/config.pyserializes string values without escaping newlines. Any config value that contains a real newline (a multi-line system prompt, or any setting saved from a UI textarea) is written as a literal line break inside a basic TOML string, which is invalid TOML.load_config()then swallows the resultingTOMLDecodeErrorand falls back to an empty cache (except Exception: _config_cache = {}). The first write that happens afterwards —sync_config_to_toml()callssave_config()after everyConfig.upsert()— persists that empty config. Result: every other section ofconfig.tomlis silently destroyed, including[server].secret,[auth]and all API keys / bot tokens kept in[app_config].No exception is raised, nothing is logged, and the damage surfaces much later — the user just finds that sessions were invalidated and settings reverted.
Affected
cptr/utils/config.py—save_config()(lines ~116-141),load_config()(lines ~45-67)main(the same pattern is present inrelease)pyproject.toml)43380c2("refac", 2026-07-23)Steps to reproduce
Stdlib only, independent of this install (
tomllibneeds Python >= 3.11):In the application the trigger path is:
Any multi-line value is stored in the DB (
app_config) — e.g.subagents.system_prompt.sync_config_to_toml()runs after the upsert (cptr/utils/config.py~line 152):On restart (or any cache invalidation),
load_config()hits the invalid TOML and returns{}.The next setting change calls
sync_config_to_toml()again:configis{}, so the "merged" result is only{"app_config": {...}}and everything else is gone.Expected
Multi-line values either round-trip correctly, or at minimum the file stays valid TOML and no other section is lost.
Actual
config.tomlis written as invalid TOML, then silently rewritten as (almost) empty, taking all unrelated sections and secrets with it.Impact
config.tomlcontents other than the section being saved.[server].secretis regenerated on the next_get_jwt_secret()call → all existing JWT sessions are invalidated.[auth]settings and every credential stored in[app_config](provider API keys, messaging bot tokens) are lost without any error message.Suggested fix
Serialize string values with a real TOML writer, or at minimum JSON-encode them (
json.dumpsalways produces a valid TOML basic string):and decode symmetrically where strings are read back.
Independently,
load_config()should stop treating "cannot parse" as "no config": catchingExceptionand returning{}is what turns a formatting bug into data loss. Failure to parse an existing file should be logged and surfaced, not silently degraded.Notes
save_config/ TOML / config loss: no match.mainandrelease: the pattern is the same in both.@owui-terminator[bot] commented on GitHub (Oct 9, 2026):
⚠️ Missing Issue Title Prefix
@adonay52-svg, your issue title is missing a categorising prefix (e.g.
bug:,feat:,docs:).Please update the title to lead with one of:
Example:
bug: Login fails when the password contains special characters