Skip to content

fix(settings): keep saved sources, plugin state and sign-ins a newer RustGIS wrote - #1962

Merged
Mavrick-F merged 17 commits into
opengeos:mainfrom
Mavrick-F:fix/settings-preserve-sources-plugins
Nov 14, 2026
Merged

Mavrick-F merged 17 commits into
opengeos:mainfrom
Mavrick-F:fix/settings-preserve-sources-plugins

Conversation

@Mavrick-F

@Mavrick-F Mavrick-F commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Summary

An older RustGIS no longer rewrites saved data sources, plugin state or the ChatGPT sign-in store without what it couldn't read. Each now keeps what it can't read unchanged, or refuses to write over it. This follows the contract in docs/maintaining.md › Saved files and settings.

Setting Before After
data_sources (favourites, recent, saved) Rows of an unknown kind, unknown fields and lists were dropped by the next save, and recording a recent source is enough to trigger one. A preference that wasn't an object was overwritten. Kept and written back unchanged. A preference that can't be read is kept byte for byte, and this session's lists still work. One notice per kind at load.
plugins/state.json (desktop) A file that couldn't be read counted as empty, and the next enable, disable or folder install overwrote it. Unknown keys were dropped. Reported by load_installed, which then loads no plugins (a disabled one may be a native program), naming the file and saying repairing or removing it brings them back. Writes are refused with an actionable error. Unknown keys are kept.
plugins_web (browser) A list that couldn't be read counted as empty and was overwritten. Entries and fields it couldn't read were dropped. Entries it can't read are kept after the others and fields are kept. A list that can't be read isn't written over. Both are said at start.
ChatGPT sign-in store version was ignored. A store from a newer RustGIS was rewritten as version 2. A version above 2 is refused before it is used or written. The writer still writes 2.
 Sources::from_json(text)
-  rows that fail clean() dropped; unknown fields/keys dropped; junk -> empty
+  rows that fail -> kept per list, appended on save
+  rows past a list's limit -> kept too, said as past the limit
+  unknown row fields / top-level keys -> kept, merged back on save
+  not an object, or a list not an array -> whole text kept, to_json() returns it
+  any of the above holding a password/key/token (holds_secret) -> dropped and counted
 sourcespane::load
+  says Sources::unread(); a change made before the first read is still saved

Notes:

  • The last line fixes a related loss. The Data Sources preference is read lazily on the first save, and that read marked everything as saved, so the source just added (usually the trigger) wasn't saved until the next change.
  • feat(plugins): plugins remember settings between runs, per plugin, erased on uninstall (#1261) #1873 also edits crates/plugins/src/store.rs, only in uninstall. This PR changes State, read_state, write_state and load_installed, so the two merge independently. Once both land, uninstall refuses before it erases a plugin's settings while state.json can't be read, because the write_state it calls first returns the error.
  • Secrets: data this version can't read that holds a password, key or token is dropped, with a notice, and not kept. data_sources and plugins/state.json carry no version, so what is kept unchanged is the rows and fields this version doesn't know and a file it can't read as a whole (which is never written over); a newer version that changed what a known field means is not detected here, and adding a version marker to these files is a format decision. The documented promise is that these lists hold no secrets. Within the shape this RustGIS reads it knows that promise, so it can tell a secret and drop it; text it can't parse it can't interpret, so that is kept byte for byte and never rewritten.
  • Rows of one list with the same kind and address (a login binding cleared) are one source (lists are keyed by that identity): at load the first row wins, with its unknown fields, and later ones are dropped and counted in one notice. Forgetting a source also removes a readable row kept past the list's limit with that identity, never a row this version can't read. Readable rows whose address, name or details clean changes are counted and reported too.
  • Left out: the extra object of a saved source is still cleaned (string values, at most 8 keys, no secret-looking keys). That filtering is a safety measure, and loosening it is a separate decision.

Testing

  • sources::tests::sources_keep_what_this_version_cannot_read: an unknown kind, unknown fields and an unknown list survive note and keep. Fields go with a source that ages out of Recent or is forgotten. Rows past a list's limit are kept and reported as such. Two unreadable shapes are kept byte for byte. Data holding a secret is dropped and said. Clean input gives no notice.
  • smoke::saved_sources_from_a_newer_version_survive_recording_a_recent_one: in the app, adding a GeoJSON file records it as recent and saves it ahead of the kept rows and fields. A preference that isn't an object stays byte for byte.
  • tests::plugin_state_keeps_what_this_version_cannot_read (plugins): an unknown key survives a disable. Two unreadable state.json shapes are reported at load with no plugin loaded, refuse enable and uninstall, and stay byte for byte; a missing file loads as before with no notice.
  • pluginsui::tests::saved_web_plugins_keep_what_this_version_cannot_read: an unknown field and an unreadable entry survive a change. A preference that isn't a list isn't read.
  • chatgpt::…::a_store_from_a_newer_version_is_kept_as_it_is: a version-3 store refuses read, sign-in, sign-out and removal, and stays byte for byte.
  • Locally: cargo fmt --check, the tests above, the existing sources and chatgpt tests, cargo clippy -D warnings and cargo check --target wasm32-unknown-unknown for engine, plugins, assistant and ui-egui. The full CI (fork run) passed on this head.

Merge danger: a two-way door. The blast radius is saved settings: a setting that was silently emptied before is now kept, and a write to it is refused or held for the session.

UI evidence

No visible UI change.

Related issue

Part of #1405 item 3 (saved sources, plugin installation state, account store). Connections are in #1945.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Settings, source preferences, and plugin data now better preserve entries and fields they cannot read, including data saved in newer formats.
    • Unreadable or unsupported saved data is protected from being overwritten. Notices identify data that could not be fully read, while readable entries can still be loaded where possible.
    • Sign-in data saved by a newer version is rejected before it can be used or changed.
    • Recent sources can be recorded without losing unrecognized saved preferences or existing entries.
    • Notices now identify when potentially sensitive source data is omitted during saving.

Loading
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